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

Function Test_Hook_OnName

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

Source from the content-addressed store, hash-verified

63}
64
65func Test_Hook_OnName(t *testing.T) {
66 t.Parallel()
67 app := New()
68
69 buf := bytebufferpool.Get()
70 defer bytebufferpool.Put(buf)
71
72 app.Hooks().OnName(func(r Route) error {
73 _, err := buf.WriteString(r.Name)
74 require.NoError(t, err)
75
76 return nil
77 })
78
79 app.Get("/", testSimpleHandler).Name("index")
80
81 subApp := New()
82 subApp.Get("/test", testSimpleHandler)
83 subApp.Get("/test2", testSimpleHandler)
84
85 app.Use("/sub", subApp)
86
87 require.Equal(t, "index", buf.String())
88}
89
90func Test_Hook_OnName_Error(t *testing.T) {
91 t.Parallel()

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected