Test_CacheAgeHeaderIsCappedAtMaxDeltaSeconds() — fiber Function Reference
Architecture documentation for the Test_CacheAgeHeaderIsCappedAtMaxDeltaSeconds() function in cache_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD eb0dffee_2b81_60c9_1ae7_42345b93db84["Test_CacheAgeHeaderIsCappedAtMaxDeltaSeconds()"] 8453a087_9678_fe96_1b20_2d125b6f8656["cache_test.go"] eb0dffee_2b81_60c9_1ae7_42345b93db84 -->|defined in| 8453a087_9678_fe96_1b20_2d125b6f8656 a76eea88_fb7a_293c_1e6a_ee5f49e6d6ae["newMutatingStorage()"] eb0dffee_2b81_60c9_1ae7_42345b93db84 -->|calls| a76eea88_fb7a_293c_1e6a_ee5f49e6d6ae style eb0dffee_2b81_60c9_1ae7_42345b93db84 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/cache/cache_test.go lines 2467–2512
func Test_CacheAgeHeaderIsCappedAtMaxDeltaSeconds(t *testing.T) {
t.Parallel()
const veryLargeAge = uint64(math.MaxInt32) + 1000
storage := newMutatingStorage(func(key string, val []byte) []byte {
if strings.HasSuffix(key, "_body") {
return val
}
var it item
if _, err := it.UnmarshalMsg(val); err != nil {
return val
}
it.age = veryLargeAge
updated, err := it.MarshalMsg(nil)
if err != nil {
return val
}
return updated
})
app := fiber.New()
app.Use(New(Config{
Expiration: time.Minute,
Storage: storage,
}))
app.Get("/", func(c fiber.Ctx) error {
c.Set(fiber.HeaderCacheControl, "public, max-age=60")
return c.SendString("body")
})
resp, err := app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
require.NoError(t, err)
require.Equal(t, cacheMiss, resp.Header.Get("X-Cache"))
resp, err = app.Test(httptest.NewRequest(fiber.MethodGet, "/", http.NoBody))
require.NoError(t, err)
require.Equal(t, cacheHit, resp.Header.Get("X-Cache"))
ageVal, err := strconv.Atoi(resp.Header.Get(fiber.HeaderAge))
require.NoError(t, err)
require.Equal(t, math.MaxInt32, ageVal)
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does Test_CacheAgeHeaderIsCappedAtMaxDeltaSeconds() do?
Test_CacheAgeHeaderIsCappedAtMaxDeltaSeconds() is a function in the fiber codebase, defined in middleware/cache/cache_test.go.
Where is Test_CacheAgeHeaderIsCappedAtMaxDeltaSeconds() defined?
Test_CacheAgeHeaderIsCappedAtMaxDeltaSeconds() is defined in middleware/cache/cache_test.go at line 2467.
What does Test_CacheAgeHeaderIsCappedAtMaxDeltaSeconds() call?
Test_CacheAgeHeaderIsCappedAtMaxDeltaSeconds() calls 1 function(s): newMutatingStorage.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free