TestGroupNotFoundHandlePriority tests that group handler takes priority over global handler
(t *testing.T)
| 88 | |
| 89 | // TestGroupNotFoundHandlePriority tests that group handler takes priority over global handler |
| 90 | func TestGroupNotFoundHandlePriority(t *testing.T) { |
| 91 | app := New() |
| 92 | |
| 93 | // Set global handler |
| 94 | app.SetNotFoundHandle(func(ctx Context) { |
| 95 | ctx.WriteString("Global Handler") |
| 96 | }) |
| 97 | |
| 98 | // Create group with handler |
| 99 | apiGroup := app.HttpServer.Group("/api") |
| 100 | apiGroup.SetNotFoundHandle(func(ctx Context) { |
| 101 | ctx.WriteString("Group Handler") |
| 102 | }) |
| 103 | |
| 104 | // Add valid route |
| 105 | apiGroup.GET("/users", func(ctx Context) error { |
| 106 | return ctx.WriteString("Users") |
| 107 | }) |
| 108 | |
| 109 | // Verify group has notFoundHandler set |
| 110 | xg := apiGroup.(*xGroup) |
| 111 | if xg.notFoundHandler == nil { |
| 112 | t.Error("Group should have notFoundHandler set") |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | // TestMultipleGroupsWithNotFoundHandle tests multiple groups with different handlers |
| 117 | func TestMultipleGroupsWithNotFoundHandle(t *testing.T) { |
nothing calls this directly
no test coverage detected