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

Function Test_App_GetRoutes

app_test.go:3113–3141  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3111}
3112
3113func Test_App_GetRoutes(t *testing.T) {
3114 t.Parallel()
3115 app := New()
3116 app.Use(func(c Ctx) error {
3117 return c.Next()
3118 })
3119 handler := func(c Ctx) error {
3120 return c.SendStatus(StatusOK)
3121 }
3122 app.Delete("/delete", handler).Name("delete")
3123 app.Post("/post", handler).Name("post")
3124 routes := app.GetRoutes(false)
3125 require.Len(t, routes, 2+len(app.config.RequestMethods))
3126 methodMap := map[string]string{"/delete": "delete", "/post": "post"}
3127 for _, route := range routes {
3128 name, ok := methodMap[route.Path]
3129 if ok {
3130 require.Equal(t, name, route.Name)
3131 }
3132 }
3133
3134 routes = app.GetRoutes(true)
3135 require.Len(t, routes, 2)
3136 for _, route := range routes {
3137 name, ok := methodMap[route.Path]
3138 require.True(t, ok)
3139 require.Equal(t, name, route.Name)
3140 }
3141}
3142
3143func Test_Middleware_Route_Naming_With_Use(t *testing.T) {
3144 t.Parallel()

Callers

nothing calls this directly

Calls 9

GetRoutesMethod · 0.80
NewFunction · 0.70
UseMethod · 0.65
NextMethod · 0.65
SendStatusMethod · 0.65
NameMethod · 0.65
DeleteMethod · 0.65
PostMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected