1
0
Fork 0
mirror of https://github.com/dirtbags/moth.git synced 2025-01-06 12:00:34 -07:00
moth/pkg/jsend/jsend_test.go
2020-08-17 17:43:57 -06:00

18 lines
443 B
Go

package jsend
import (
"net/http/httptest"
"testing"
)
func TestEverything(t *testing.T) {
w := httptest.NewRecorder()
Sendf(w, Success, "You have cows", "You have %d cows", 12)
if w.Result().StatusCode != 200 {
t.Errorf("HTTP Status code: %d", w.Result().StatusCode)
}
if w.Body.String() != `{"status":"success","data":{"short":"You have cows","description":"You have 12 cows"}}` {
t.Errorf("HTTP Body %s", w.Body.Bytes())
}
}