Test_CachePermanentRedirectCached() — fiber Function Reference
Architecture documentation for the Test_CachePermanentRedirectCached() function in cache_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD 563233da_1cac_caba_4980_7f7c81bc5c27["Test_CachePermanentRedirectCached()"] 8453a087_9678_fe96_1b20_2d125b6f8656["cache_test.go"] 563233da_1cac_caba_4980_7f7c81bc5c27 -->|defined in| 8453a087_9678_fe96_1b20_2d125b6f8656 style 563233da_1cac_caba_4980_7f7c81bc5c27 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/cache/cache_test.go lines 2551–2588
func Test_CachePermanentRedirectCached(t *testing.T) {
t.Parallel()
app := fiber.New()
app.Use(New(Config{
Expiration: 30 * time.Second,
StoreResponseHeaders: true,
KeyGenerator: func(c fiber.Ctx) string {
return c.Path() + "|status-308"
},
}))
var count int
app.Get("/", func(c fiber.Ctx) error {
count++
c.Set(fiber.HeaderCacheControl, "public, max-age=30")
c.Set(fiber.HeaderLocation, "/dest")
return c.Status(fiber.StatusPermanentRedirect).SendString("redir" + strconv.Itoa(count))
})
resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
require.NoError(t, err)
require.Equal(t, cacheMiss, resp.Header.Get("X-Cache"))
require.Equal(t, fiber.StatusPermanentRedirect, resp.StatusCode)
body, err := io.ReadAll(resp.Body)
require.NoError(t, err)
require.Equal(t, "redir1", string(body))
require.Equal(t, "/dest", resp.Header.Get(fiber.HeaderLocation))
resp, err = app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
require.NoError(t, err)
require.Equal(t, cacheHit, resp.Header.Get("X-Cache"))
require.Equal(t, fiber.StatusPermanentRedirect, resp.StatusCode)
body, err = io.ReadAll(resp.Body)
require.NoError(t, err)
require.Equal(t, "redir1", string(body))
require.Equal(t, "/dest", resp.Header.Get(fiber.HeaderLocation))
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_CachePermanentRedirectCached() do?
Test_CachePermanentRedirectCached() is a function in the fiber codebase, defined in middleware/cache/cache_test.go.
Where is Test_CachePermanentRedirectCached() defined?
Test_CachePermanentRedirectCached() is defined in middleware/cache/cache_test.go at line 2551.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free