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

Function Test_Ctx_RestartRoutingWithChangedPathAndCatchAll

ctx_test.go:8004–8022  ·  view source on GitHub ↗

go test -run Test_Ctx_RestartRoutingWithChangedPathAnd404

(t *testing.T)

Source from the content-addressed store, hash-verified

8002
8003// go test -run Test_Ctx_RestartRoutingWithChangedPathAnd404
8004func Test_Ctx_RestartRoutingWithChangedPathAndCatchAll(t *testing.T) {
8005 t.Parallel()
8006 app := New()
8007 app.Get("/new", func(_ Ctx) error {
8008 return nil
8009 })
8010 app.Use(func(c Ctx) error {
8011 c.Path("/new")
8012 // c.Next() would fail this test as a 404 is returned from the next handler
8013 return c.RestartRouting()
8014 })
8015 app.Use(func(_ Ctx) error {
8016 return ErrNotFound
8017 })
8018
8019 resp, err := app.Test(httptest.NewRequest(MethodGet, "http://example.com/old", http.NoBody))
8020 require.NoError(t, err, "app.Test(req)")
8021 require.Equal(t, StatusOK, resp.StatusCode, "Status code")
8022}
8023
8024type testTemplateEngine struct {
8025 templates *template.Template

Callers

nothing calls this directly

Calls 6

TestMethod · 0.80
NewFunction · 0.70
GetMethod · 0.65
UseMethod · 0.65
PathMethod · 0.65
RestartRoutingMethod · 0.65

Tested by

no test coverage detected