(t *testing.T)
| 64 | } |
| 65 | |
| 66 | func TestCache_Clear(t *testing.T) { |
| 67 | cache := createTestCache(t) |
| 68 | |
| 69 | items := map[string]string{ |
| 70 | "key1": "value1", |
| 71 | "key2": "value2", |
| 72 | "key3": "value3", |
| 73 | } |
| 74 | |
| 75 | for key, value := range items { |
| 76 | cache.Set(key, value, time.Minute) |
| 77 | } |
| 78 | |
| 79 | for key := range items { |
| 80 | _, ok := cache.Get(key) |
| 81 | require.True(t, ok, "All items should exist before clear") |
| 82 | } |
| 83 | |
| 84 | cache.Clear() |
| 85 | |
| 86 | for key := range items { |
| 87 | _, ok := cache.Get(key) |
| 88 | assert.False(t, ok, "No items should exist after clear") |
| 89 | } |
| 90 | |
| 91 | t.Run("should be empty after clear", func(t *testing.T) { |
| 92 | cache.Set("new-key", "new-value", time.Minute) |
| 93 | got, ok := cache.Get("new-key") |
| 94 | assert.True(t, ok) |
| 95 | assert.Equal(t, "new-value", got, "Should work normally after clear") |
| 96 | }) |
| 97 | } |
| 98 | |
| 99 | func TestCache_Expiration(t *testing.T) { |
| 100 | if testing.Short() { |
nothing calls this directly
no test coverage detected