Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (26 sloc) 0.693 kb
package mockhttp
import (
// CheckResponse checks that the http response matches expectations,
// and calls t.Error if not.
func CheckResponse(t *testing.T, w *httptest.ResponseRecorder, wantStatus int, wantHeaders http.Header, wantBody string) (ok bool) {
ok = true
if w.Code != wantStatus {
t.Errorf("Bad HTTP status: got %d want %d", w.Code, wantStatus)
ok = false
if !reflect.DeepEqual(w.HeaderMap, wantHeaders) {
t.Errorf("Bad HTTP response headers: %v", w.HeaderMap)
ok = false
respBody := w.Body.String()
if respBody != wantBody {
t.Errorf("Bad HTTP response body: %q", respBody)
ok = false
Jump to Line
Something went wrong with that request. Please try again.