mirror of
https://github.com/status-im/fathom.git
synced 2025-03-01 03:20:27 +00:00
26 lines
428 B
Go
26 lines
428 B
Go
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestRespond(t *testing.T) {
|
|
w := httptest.NewRecorder()
|
|
respond(w, 15)
|
|
|
|
// assert json header
|
|
if w.Header().Get("Content-Type") != "application/json" {
|
|
t.Errorf("Invalid Content-Type header")
|
|
}
|
|
|
|
// assert json response
|
|
var d int
|
|
err := json.NewDecoder(w.Body).Decode(&d)
|
|
if err != nil {
|
|
t.Errorf("Invalid response body: %s", err)
|
|
}
|
|
|
|
}
|