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

Function Test_CustomKey

middleware/cache/cache_test.go:1540–1558  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1538}
1539
1540func Test_CustomKey(t *testing.T) {
1541 t.Parallel()
1542
1543 app := fiber.New()
1544 var called bool
1545 app.Use(New(Config{KeyGenerator: func(c fiber.Ctx) string {
1546 called = true
1547 return utils.CopyString(c.Path())
1548 }}))
1549
1550 app.Get("/", func(c fiber.Ctx) error {
1551 return c.SendString("hi")
1552 })
1553
1554 req := httptest.NewRequest(fiber.MethodGet, "/", http.NoBody)
1555 _, err := app.Test(req)
1556 require.NoError(t, err)
1557 require.True(t, called)
1558}
1559
1560func Test_CustomExpiration(t *testing.T) {
1561 t.Parallel()

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