Test_Cache_WithHead() — fiber Function Reference
Architecture documentation for the Test_Cache_WithHead() function in cache_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD 786d085e_faf9_15a4_cd49_a8d745b38b2f["Test_Cache_WithHead()"] 8453a087_9678_fe96_1b20_2d125b6f8656["cache_test.go"] 786d085e_faf9_15a4_cd49_a8d745b38b2f -->|defined in| 8453a087_9678_fe96_1b20_2d125b6f8656 style 786d085e_faf9_15a4_cd49_a8d745b38b2f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/cache/cache_test.go lines 1184–1215
func Test_Cache_WithHead(t *testing.T) {
t.Parallel()
app := fiber.New()
app.Use(New())
count := 0
handler := func(c fiber.Ctx) error {
count++
c.Response().Header.Add("Cache-Time", "1")
return c.SendString(strconv.Itoa(count))
}
app.RouteChain("/").Get(handler).Head(handler)
req := httptest.NewRequest(fiber.MethodHead, "/", http.NoBody)
resp, err := app.Test(req)
require.NoError(t, err)
require.Equal(t, cacheMiss, resp.Header.Get("X-Cache"))
cachedReq := httptest.NewRequest(fiber.MethodHead, "/", http.NoBody)
cachedResp, err := app.Test(cachedReq)
require.NoError(t, err)
require.Equal(t, cacheHit, cachedResp.Header.Get("X-Cache"))
body, err := io.ReadAll(resp.Body)
require.NoError(t, err)
cachedBody, err := io.ReadAll(cachedResp.Body)
require.NoError(t, err)
require.Equal(t, cachedBody, body)
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_Cache_WithHead() do?
Test_Cache_WithHead() is a function in the fiber codebase, defined in middleware/cache/cache_test.go.
Where is Test_Cache_WithHead() defined?
Test_Cache_WithHead() is defined in middleware/cache/cache_test.go at line 1184.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free