Initial commit from mattermost-plugin-starter-template

This commit is contained in:
Felipe M 2025-07-30 13:12:52 +02:00
commit acbc69f7eb
No known key found for this signature in database
GPG key ID: 52E5D65FCF99808A
57 changed files with 27772 additions and 0 deletions

29
server/plugin_test.go Normal file
View file

@ -0,0 +1,29 @@
package main
import (
"io"
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
)
func TestServeHTTP(t *testing.T) {
assert := assert.New(t)
plugin := Plugin{}
w := httptest.NewRecorder()
r := httptest.NewRequest(http.MethodGet, "/api/v1/hello", nil)
r.Header.Set("Mattermost-User-ID", "test-user-id")
plugin.ServeHTTP(nil, w, r)
result := w.Result()
assert.NotNil(result)
defer result.Body.Close()
bodyBytes, err := io.ReadAll(result.Body)
assert.Nil(err)
bodyString := string(bodyBytes)
assert.Equal("Hello, world!", bodyString)
}