MCPcopy
hub / github.com/autobrr/qui / TestResultCache_TTLExpiry

Function TestResultCache_TTLExpiry

internal/services/metadata/cache_test.go:101–122  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

99}
100
101func TestResultCache_TTLExpiry(t *testing.T) {
102 t.Parallel()
103
104 c := newResultCache()
105
106 // Manually store an entry that is already expired.
107 key := cacheKey("Expired Show", 1)
108 c.entries.Store(key, cacheEntry{
109 count: 10,
110 expires: time.Now().Add(-1 * time.Second),
111 })
112
113 _, ok := c.Get("Expired Show", 1)
114 if ok {
115 t.Fatal("expected cache miss for expired entry")
116 }
117
118 // Confirm the expired entry was cleaned up.
119 if _, loaded := c.entries.Load(key); loaded {
120 t.Error("expired entry should have been deleted from map")
121 }
122}

Callers

nothing calls this directly

Calls 6

newResultCacheFunction · 0.85
AddMethod · 0.80
cacheKeyFunction · 0.70
StoreMethod · 0.65
GetMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected