Skip to content

Commit

Permalink
Added in a test case for when caduceus is queried with a bad method…
Browse files Browse the repository at this point in the history
… (a.k.a. not POST)
  • Loading branch information
Holaday, Sean authored and Holaday, Sean committed Apr 13, 2017
1 parent 8c22cf4 commit 4a179f5
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/caduceus/caduceus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ func TestServerHandler(t *testing.T) {
}

req := httptest.NewRequest("POST", "localhost:8080", strings.NewReader("Test payload."))
badReq := httptest.NewRequest("GET", "localhost:8080", strings.NewReader("Test payload."))

t.Run("TestServeHTTPHappyPath", func(t *testing.T) {
req.Header.Set("Content-Type", "application/json")
Expand All @@ -151,6 +152,18 @@ func TestServerHandler(t *testing.T) {
fakeHealth.AssertExpectations(t)
})

t.Run("TestServeHTTPBadMethod", func(t *testing.T) {
badReq.Header.Set("Content-Type", "application/json")

w := httptest.NewRecorder()
serverWrapper.ServeHTTP(w, badReq)
resp := w.Result()

assert.Equal(400, resp.StatusCode)
fakeHandler.AssertExpectations(t)
fakeHealth.AssertExpectations(t)
})

t.Run("TestServeHTTPTooManyHeaders", func(t *testing.T) {
req.Header.Add("Content-Type", "too/many/headers")

Expand Down

0 comments on commit 4a179f5

Please sign in to comment.