From 081fb8a5c2575f401e606a7d839e06eb79f9d5d5 Mon Sep 17 00:00:00 2001 From: Jason McCallister Date: Mon, 23 Oct 2017 22:46:32 -0400 Subject: [PATCH] Add additional test for method not found --- examples/handler_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/examples/handler_test.go b/examples/handler_test.go index b9a5b3d..34c0bc5 100644 --- a/examples/handler_test.go +++ b/examples/handler_test.go @@ -100,3 +100,19 @@ func TestHttpErrorWhenHeaderDoesNotMatch(t *testing.T) { t.Fatal("expected Unsupported Media Type staus error") } } + +func TestHttpErrorWhenMethodDoesNotMatch(t *testing.T) { + r, err := http.NewRequest(http.MethodPatch, "/blogs", nil) + if err != nil { + t.Fatal(err) + } + r.Header.Set(headerAccept, jsonapi.MediaType) + + rr := httptest.NewRecorder() + handler := &ExampleHandler{} + handler.ServeHTTP(rr, r) + + if rr.Code != http.StatusNotFound { + t.Fatal("expected HTTP Status Not Found status error") + } +}