Skip to content

Commit 081fb8a

Browse files
Add additional test for method not found
1 parent c036316 commit 081fb8a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

examples/handler_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,19 @@ func TestHttpErrorWhenHeaderDoesNotMatch(t *testing.T) {
100100
t.Fatal("expected Unsupported Media Type staus error")
101101
}
102102
}
103+
104+
func TestHttpErrorWhenMethodDoesNotMatch(t *testing.T) {
105+
r, err := http.NewRequest(http.MethodPatch, "/blogs", nil)
106+
if err != nil {
107+
t.Fatal(err)
108+
}
109+
r.Header.Set(headerAccept, jsonapi.MediaType)
110+
111+
rr := httptest.NewRecorder()
112+
handler := &ExampleHandler{}
113+
handler.ServeHTTP(rr, r)
114+
115+
if rr.Code != http.StatusNotFound {
116+
t.Fatal("expected HTTP Status Not Found status error")
117+
}
118+
}

0 commit comments

Comments
 (0)