moth

Monarch Of The Hill game server
git clone https://git.woozle.org/neale/moth.git

moth / pkg / jsend
Neale Pickett  ·  2020-08-17

jsend_test.go

 1package jsend
 2
 3import (
 4	"net/http/httptest"
 5	"testing"
 6)
 7
 8func TestEverything(t *testing.T) {
 9	w := httptest.NewRecorder()
10
11	Sendf(w, Success, "You have cows", "You have %d cows", 12)
12	if w.Result().StatusCode != 200 {
13		t.Errorf("HTTP Status code: %d", w.Result().StatusCode)
14	}
15	if w.Body.String() != `{"status":"success","data":{"short":"You have cows","description":"You have 12 cows"}}` {
16		t.Errorf("HTTP Body %s", w.Body.Bytes())
17	}
18}