forked from Mirrors/jsonapi
Add tests for mismatching accept headers
This commit is contained in:
parent
a06052dd83
commit
c036316c9d
|
@ -84,3 +84,19 @@ func TestExampleHandler_get_list(t *testing.T) {
|
||||||
t.Fatalf("Expected a status of %d, got %d", e, a)
|
t.Fatalf("Expected a status of %d, got %d", e, a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestHttpErrorWhenHeaderDoesNotMatch(t *testing.T) {
|
||||||
|
r, err := http.NewRequest(http.MethodGet, "/blogs", nil)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
r.Header.Set(headerAccept, "application/xml")
|
||||||
|
|
||||||
|
rr := httptest.NewRecorder()
|
||||||
|
handler := &ExampleHandler{}
|
||||||
|
handler.ServeHTTP(rr, r)
|
||||||
|
|
||||||
|
if rr.Code != http.StatusUnsupportedMediaType {
|
||||||
|
t.Fatal("expected Unsupported Media Type staus error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue