Skip to content

Instantly share code, notes, and snippets.

@crgimenes
Created February 22, 2018 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crgimenes/27089081f0ef868e3d5f0d7bc0c07660 to your computer and use it in GitHub Desktop.
Save crgimenes/27089081f0ef868e3d5f0d7bc0c07660 to your computer and use it in GitHub Desktop.
test httphandler example
func TestHTTPHandler(t *testing.T) {
w := httptest.NewRecorder()
expected := "{\n\t\"error\": \"test error\"\n}\n"
HTTPHandler(w, nil)
b := w.Body.Bytes()
if string(b) != expected {
t.Errorf("expected %q, want %q", expected, string(b))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment