MCPcopy Create free account
hub / github.com/MertJSX/folderhost / TestCache_Expiration

Function TestCache_Expiration

test/cache_test.go:99–128  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

97}
98
99func TestCache_Expiration(t *testing.T) {
100 if testing.Short() {
101 t.Skip("Skipping expiration test in short mode")
102 }
103
104 cache := createTestCache(t)
105
106 t.Run("should expire after TTL", func(t *testing.T) {
107 key := "expiring-key"
108 cache.Set(key, "value", 500*time.Millisecond)
109
110 _, ok := cache.Get(key)
111 assert.True(t, ok, "Should exist before expiration")
112
113 time.Sleep(1500 * time.Millisecond)
114
115 _, ok = cache.Get(key)
116 assert.False(t, ok, "Should not exist after TTL")
117 })
118
119 t.Run("should not expire before TTL", func(t *testing.T) {
120 key := "non-expiring-key"
121 cache.Set(key, "value", 2*time.Second)
122
123 time.Sleep(1 * time.Second)
124
125 _, ok := cache.Get(key)
126 assert.True(t, ok, "Should still exist before TTL")
127 })
128}
129
130func TestCache_ConcurrentAccess(t *testing.T) {
131 cache := createTestCache(t)

Callers

nothing calls this directly

Calls 3

createTestCacheFunction · 0.85
SetMethod · 0.80
GetMethod · 0.80

Tested by

no test coverage detected