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

Function Test_Next_SkipNonUseRoutesSkipsFallback

router_test.go:1934–1953  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1932}
1933
1934func Test_Next_SkipNonUseRoutesSkipsFallback(t *testing.T) {
1935 t.Parallel()
1936
1937 app := New()
1938 app.Get("/foo", func(c Ctx) error { return c.SendStatus(StatusOK) })
1939 app.startupProcess()
1940
1941 fctx := &fasthttp.RequestCtx{}
1942 fctx.Request.Header.SetMethod(MethodPost)
1943 fctx.Request.SetRequestURI("/foo")
1944
1945 ctx := app.AcquireCtx(fctx).(*DefaultCtx) //nolint:errcheck,forcetypeassert // default app returns DefaultCtx
1946 ctx.setSkipNonUseRoutes(true)
1947 defer app.ReleaseCtx(ctx)
1948
1949 matched, err := app.next(ctx)
1950 require.False(t, matched)
1951 require.NoError(t, err)
1952 require.Empty(t, ctx.Response().Header.Peek(HeaderAllow))
1953}
1954
1955func Test_NextCustom_MethodNotAllowed(t *testing.T) {
1956 t.Parallel()

Callers

nothing calls this directly

Calls 10

startupProcessMethod · 0.80
SetMethodMethod · 0.80
AcquireCtxMethod · 0.80
ReleaseCtxMethod · 0.80
NewFunction · 0.70
GetMethod · 0.65
SendStatusMethod · 0.65
setSkipNonUseRoutesMethod · 0.65
ResponseMethod · 0.65
nextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…