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

Function Test_Next

middleware/helmet/helmet_test.go:131–155  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

129}
130
131func Test_Next(t *testing.T) {
132 app := fiber.New()
133
134 app.Use(New(Config{
135 Next: func(ctx fiber.Ctx) bool {
136 return ctx.Path() == "/next"
137 },
138 ReferrerPolicy: "no-referrer",
139 }))
140
141 app.Get("/", func(c fiber.Ctx) error {
142 return c.SendString("Hello, World!")
143 })
144 app.Get("/next", func(c fiber.Ctx) error {
145 return c.SendString("Skipped!")
146 })
147
148 resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
149 require.NoError(t, err)
150 require.Equal(t, "no-referrer", resp.Header.Get(fiber.HeaderReferrerPolicy))
151
152 resp, err = app.Test(httptest.NewRequest(fiber.MethodGet, "/next", http.NoBody))
153 require.NoError(t, err)
154 require.Empty(t, resp.Header.Get(fiber.HeaderReferrerPolicy))
155}
156
157func Test_ContentSecurityPolicy(t *testing.T) {
158 app := fiber.New()

Callers

nothing calls this directly

Calls 7

TestMethod · 0.80
NewFunction · 0.70
NewMethod · 0.65
UseMethod · 0.65
PathMethod · 0.65
GetMethod · 0.65
SendStringMethod · 0.65

Tested by

no test coverage detected