MCPcopy
hub / github.com/gofiber/fiber / Test_Hook_OnGroupName

Function Test_Hook_OnGroupName

hooks_test.go:139–169  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

137}
138
139func Test_Hook_OnGroupName(t *testing.T) {
140 t.Parallel()
141 app := New()
142
143 buf := bytebufferpool.Get()
144 defer bytebufferpool.Put(buf)
145
146 buf2 := bytebufferpool.Get()
147 defer bytebufferpool.Put(buf2)
148
149 app.Hooks().OnGroupName(func(g Group) error {
150 _, err := buf.WriteString(g.name)
151 require.NoError(t, err)
152
153 return nil
154 })
155
156 app.Hooks().OnName(func(r Route) error {
157 _, err := buf2.WriteString(r.Name)
158 require.NoError(t, err)
159
160 return nil
161 })
162
163 grp := app.Group("/x").Name("x.")
164 grp.Get("/test", testSimpleHandler).Name("test")
165 grp.Get("/test2", testSimpleHandler)
166
167 require.Equal(t, "x.", buf.String())
168 require.Equal(t, "x.test", buf2.String())
169}
170
171func Test_Hook_OnGroupName_Error(t *testing.T) {
172 t.Parallel()

Callers

nothing calls this directly

Calls 10

OnGroupNameMethod · 0.80
HooksMethod · 0.80
OnNameMethod · 0.80
NewFunction · 0.70
GetMethod · 0.65
PutMethod · 0.65
WriteStringMethod · 0.65
NameMethod · 0.65
GroupMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected