update test for respond func

This commit is contained in:
Danny van Kooten 2018-09-21 10:50:34 +02:00
parent 734d32082a
commit 5507fbcd92
1 changed files with 7 additions and 2 deletions

View File

@ -2,17 +2,22 @@ package api
import (
"encoding/json"
"net/http"
"net/http/httptest"
"testing"
)
func TestRespond(t *testing.T) {
w := httptest.NewRecorder()
respond(w, 15)
respond(w, http.StatusOK, 15)
if w.Code != 200 {
t.Errorf("Invalid response code")
}
// assert json header
if w.Header().Get("Content-Type") != "application/json" {
t.Errorf("Invalid Content-Type header")
t.Errorf("Invalid response header for Content-Type")
}
// assert json response