MCPcopy Create free account
hub / github.com/devfeel/dotweb / TestGroupNotFoundHandlePriority

Function TestGroupNotFoundHandlePriority

group_test.go:90–114  ·  view source on GitHub ↗

TestGroupNotFoundHandlePriority tests that group handler takes priority over global handler

(t *testing.T)

Source from the content-addressed store, hash-verified

88
89// TestGroupNotFoundHandlePriority tests that group handler takes priority over global handler
90func 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
117func TestMultipleGroupsWithNotFoundHandle(t *testing.T) {

Callers

nothing calls this directly

Calls 6

NewFunction · 0.85
SetNotFoundHandleMethod · 0.65
WriteStringMethod · 0.65
GroupMethod · 0.65
GETMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected