Test_CacheClampsInvalidStoredDate() — fiber Function Reference
Architecture documentation for the Test_CacheClampsInvalidStoredDate() function in cache_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD f2cbcff5_0b48_ba3b_5319_d2a265d9e0f9["Test_CacheClampsInvalidStoredDate()"] 8453a087_9678_fe96_1b20_2d125b6f8656["cache_test.go"] f2cbcff5_0b48_ba3b_5319_d2a265d9e0f9 -->|defined in| 8453a087_9678_fe96_1b20_2d125b6f8656 a76eea88_fb7a_293c_1e6a_ee5f49e6d6ae["newMutatingStorage()"] f2cbcff5_0b48_ba3b_5319_d2a265d9e0f9 -->|calls| a76eea88_fb7a_293c_1e6a_ee5f49e6d6ae style f2cbcff5_0b48_ba3b_5319_d2a265d9e0f9 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
middleware/cache/cache_test.go lines 2163–2212
func Test_CacheClampsInvalidStoredDate(t *testing.T) {
t.Parallel()
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.date = uint64(math.MaxInt64) + 1024
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("ok")
})
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"))
parsedDate, err := http.ParseTime(resp.Header.Get(fiber.HeaderDate))
require.NoError(t, err)
require.WithinDuration(t, time.Now(), parsedDate, time.Minute)
ageVal, err := strconv.Atoi(resp.Header.Get(fiber.HeaderAge))
require.NoError(t, err)
require.Less(t, ageVal, 60)
require.GreaterOrEqual(t, ageVal, 0)
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does Test_CacheClampsInvalidStoredDate() do?
Test_CacheClampsInvalidStoredDate() is a function in the fiber codebase, defined in middleware/cache/cache_test.go.
Where is Test_CacheClampsInvalidStoredDate() defined?
Test_CacheClampsInvalidStoredDate() is defined in middleware/cache/cache_test.go at line 2163.
What does Test_CacheClampsInvalidStoredDate() call?
Test_CacheClampsInvalidStoredDate() 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