Added simple testing documentation and examples (#1156)

This commit is contained in:
Andrii Bubis
2017-11-12 07:37:32 +02:00
committed by Bo-Yi Wu
parent 9a4ecc87d6
commit 80f691159f
3 changed files with 72 additions and 1 deletions
+20
View File
@@ -0,0 +1,20 @@
package main
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
)
func TestPingRoute(t *testing.T) {
router := setupRouter()
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/ping", nil)
router.ServeHTTP(w, req)
assert.Equal(t, 200, w.Code)
assert.Equal(t, "pong", w.Body.String())
}