Skip to content

Commit

Permalink
test: add default repsonse test
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgtaylor committed Apr 22, 2022
1 parent 8fa8055 commit f7e9477
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,3 +462,19 @@ func TestSubResource(t *testing.T) {
// Do nothing
})
}

func TestDefaultResponse(t *testing.T) {
app := newTestRouter()

// This should not crash.
app.Resource("/").Get("get-root", "docs", NewResponse(0, "Default repsonse")).Run(func(ctx Context) {
ctx.WriteHeader(http.StatusOK)
})

w := httptest.NewRecorder()
req, _ := http.NewRequest(http.MethodGet, "/", nil)
app.ServeHTTP(w, req)

// This should not panic and should return the 200 OK
assert.Equal(t, http.StatusOK, w.Result().StatusCode)
}

0 comments on commit f7e9477

Please sign in to comment.