Add hello world http methode and test

This commit is contained in:
Hanzei 2018-10-02 23:41:34 +02:00
parent 5befc9b69f
commit c1397f440e
No known key found for this signature in database
GPG key ID: 69A2DEFD98937BA0
2 changed files with 32 additions and 0 deletions

26
server/plugin_test.go Normal file
View file

@ -0,0 +1,26 @@
package main
import (
"io/ioutil"
"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("GET", "/", nil)
plugin.ServeHTTP(nil, w, r)
result := w.Result()
assert.NotNil(result)
bodyBytes, err := ioutil.ReadAll(result.Body)
assert.Nil(err)
bodyString := string(bodyBytes)
assert.Equal("Hello, world!", bodyString)
}