Test_CachePrivateDirectiveInvalidatesExistingEntry() — fiber Function Reference
Architecture documentation for the Test_CachePrivateDirectiveInvalidatesExistingEntry() function in cache_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD f5125cd5_c394_0e89_e973_78cad56ab8a0["Test_CachePrivateDirectiveInvalidatesExistingEntry()"] 8453a087_9678_fe96_1b20_2d125b6f8656["cache_test.go"] f5125cd5_c394_0e89_e973_78cad56ab8a0 -->|defined in| 8453a087_9678_fe96_1b20_2d125b6f8656 style f5125cd5_c394_0e89_e973_78cad56ab8a0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/cache/cache_test.go lines 2904–2945
func Test_CachePrivateDirectiveInvalidatesExistingEntry(t *testing.T) {
t.Parallel()
app := fiber.New()
app.Use(New())
var privateMode atomic.Bool
app.Get("/", func(c fiber.Ctx) error {
if privateMode.Load() {
c.Set(fiber.HeaderCacheControl, "private")
return c.SendString("private")
}
c.Set(fiber.HeaderCacheControl, "public, max-age=60")
return c.SendString("public")
})
resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
require.NoError(t, err)
require.Equal(t, cacheMiss, resp.Header.Get("X-Cache"))
body, err := io.ReadAll(resp.Body)
require.NoError(t, err)
require.Equal(t, "public", string(body))
privateMode.Store(true)
req := httptest.NewRequest(fiber.MethodGet, "/", http.NoBody)
req.Header.Set(fiber.HeaderCacheControl, "no-cache")
resp, err = app.Test(req)
require.NoError(t, err)
require.Equal(t, cacheUnreachable, resp.Header.Get("X-Cache"))
body, err = io.ReadAll(resp.Body)
require.NoError(t, err)
require.Equal(t, "private", string(body))
privateMode.Store(false)
resp, err = app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
require.NoError(t, err)
require.Equal(t, cacheMiss, resp.Header.Get("X-Cache"))
body, err = io.ReadAll(resp.Body)
require.NoError(t, err)
require.Equal(t, "public", string(body))
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_CachePrivateDirectiveInvalidatesExistingEntry() do?
Test_CachePrivateDirectiveInvalidatesExistingEntry() is a function in the fiber codebase, defined in middleware/cache/cache_test.go.
Where is Test_CachePrivateDirectiveInvalidatesExistingEntry() defined?
Test_CachePrivateDirectiveInvalidatesExistingEntry() is defined in middleware/cache/cache_test.go at line 2904.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free