mirror of
https://github.com/status-im/fathom.git
synced 2025-03-01 11:30:28 +00:00
update test for respond func
This commit is contained in:
parent
734d32082a
commit
5507fbcd92
@ -2,17 +2,22 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestRespond(t *testing.T) {
|
func TestRespond(t *testing.T) {
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
respond(w, 15)
|
respond(w, http.StatusOK, 15)
|
||||||
|
|
||||||
|
if w.Code != 200 {
|
||||||
|
t.Errorf("Invalid response code")
|
||||||
|
}
|
||||||
|
|
||||||
// assert json header
|
// assert json header
|
||||||
if w.Header().Get("Content-Type") != "application/json" {
|
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
|
// assert json response
|
||||||
|
Loading…
x
Reference in New Issue
Block a user