Test_Cache_MaxBytes_InsufficientSpace() — fiber Function Reference
Architecture documentation for the Test_Cache_MaxBytes_InsufficientSpace() function in cache_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD 77c5626b_1268_4a06_2e5d_21e7787ba6b2["Test_Cache_MaxBytes_InsufficientSpace()"] 8453a087_9678_fe96_1b20_2d125b6f8656["cache_test.go"] 77c5626b_1268_4a06_2e5d_21e7787ba6b2 -->|defined in| 8453a087_9678_fe96_1b20_2d125b6f8656 d85d9be6_add5_aae9_e8ed_6409b730b1bf["stableAscendingExpiration()"] 77c5626b_1268_4a06_2e5d_21e7787ba6b2 -->|calls| d85d9be6_add5_aae9_e8ed_6409b730b1bf style 77c5626b_1268_4a06_2e5d_21e7787ba6b2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/cache/cache_test.go lines 3804–3854
func Test_Cache_MaxBytes_InsufficientSpace(t *testing.T) {
t.Parallel()
t.Run("entry larger than MaxBytes with empty cache", func(t *testing.T) {
t.Parallel()
app := fiber.New()
app.Use(New(Config{
MaxBytes: 10, // Very small cache
Expiration: 1 * time.Hour,
}))
app.Get("/large", func(c fiber.Ctx) error {
// Return data larger than MaxBytes
return c.Send(make([]byte, 20))
})
rsp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/large", http.NoBody))
require.NoError(t, err)
// Should be unreachable because entry is too large
require.Equal(t, cacheUnreachable, rsp.Header.Get("X-Cache"))
})
t.Run("entry larger than MaxBytes after eviction", func(t *testing.T) {
t.Parallel()
app := fiber.New()
app.Use(New(Config{
MaxBytes: 15,
ExpirationGenerator: stableAscendingExpiration(),
}))
app.Get("/*", func(c fiber.Ctx) error {
path := c.Path()
if path == "/small" {
return c.Send(make([]byte, 5))
}
return c.Send(make([]byte, 20))
})
// Cache a small entry first
rsp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/small", http.NoBody))
require.NoError(t, err)
require.Equal(t, cacheMiss, rsp.Header.Get("X-Cache"))
// Try to cache a large entry - should return unreachable since it won't fit even after eviction
rsp, err = app.Test(httptest.NewRequest(fiber.MethodGet, "/large", http.NoBody))
require.NoError(t, err)
require.Equal(t, cacheUnreachable, rsp.Header.Get("X-Cache"))
})
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_Cache_MaxBytes_InsufficientSpace() do?
Test_Cache_MaxBytes_InsufficientSpace() is a function in the fiber codebase, defined in middleware/cache/cache_test.go.
Where is Test_Cache_MaxBytes_InsufficientSpace() defined?
Test_Cache_MaxBytes_InsufficientSpace() is defined in middleware/cache/cache_test.go at line 3804.
What does Test_Cache_MaxBytes_InsufficientSpace() call?
Test_Cache_MaxBytes_InsufficientSpace() calls 1 function(s): stableAscendingExpiration.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free