(t *testing.T)
| 97 | } |
| 98 | |
| 99 | func 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 | |
| 130 | func TestCache_ConcurrentAccess(t *testing.T) { |
| 131 | cache := createTestCache(t) |
nothing calls this directly
no test coverage detected