mirror of
https://github.com/Fishwaldo/huma.git
synced 2025-03-15 11:21:42 +00:00
test: add default repsonse test
This commit is contained in:
parent
8fa8055c5f
commit
f7e947707a
1 changed files with 16 additions and 0 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue