mirror of
https://github.com/infinite-iroha/touka.git
synced 2026-06-13 15:47:38 +08:00
fix: avoid fixed-path miss panic and trim 405 fallback work
This commit is contained in:
parent
fa027347d3
commit
987ea81329
2 changed files with 27 additions and 5 deletions
|
|
@ -48,6 +48,24 @@ func TestHandleRequestKeepsFixedPathLookupForUppercaseMiss(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestHandleRequestFixedPathLookupMissDoesNotPanic(t *testing.T) {
|
||||
engine := New()
|
||||
engine.GET("/Users/Profile", func(c *Context) {
|
||||
c.Status(http.StatusNoContent)
|
||||
})
|
||||
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
t.Fatalf("unexpected panic for fixed-path miss: %v", r)
|
||||
}
|
||||
}()
|
||||
|
||||
rr := PerformRequest(engine, http.MethodGet, "/users/unknown", nil, nil)
|
||||
if rr.Code != http.StatusNotFound {
|
||||
t.Fatalf("expected fixed-path miss to stay as 404, got %d", rr.Code)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNoRouteCanContinueToDefaultNotFound(t *testing.T) {
|
||||
engine := New()
|
||||
engine.NoRoute(func(c *Context) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue