(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestCache_SetAndGet(t *testing.T) { |
| 13 | cache := createTestCache(t) |
| 14 | |
| 15 | t.Run("should set and get value successfully", func(t *testing.T) { |
| 16 | key := "test-key" |
| 17 | value := "test-value" |
| 18 | |
| 19 | cache.Set(key, value, time.Minute) |
| 20 | |
| 21 | got, ok := cache.Get(key) |
| 22 | assert.True(t, ok, "Get should return true for existing key") |
| 23 | assert.Equal(t, value, got, "Get should return correct value") |
| 24 | }) |
| 25 | |
| 26 | t.Run("should return false for non-existent key", func(t *testing.T) { |
| 27 | _, ok := cache.Get("non-existent") |
| 28 | assert.False(t, ok, "Get should return false for non-existent key") |
| 29 | }) |
| 30 | |
| 31 | t.Run("should override existing key", func(t *testing.T) { |
| 32 | key := "same-key" |
| 33 | |
| 34 | cache.Set(key, "first-value", time.Minute) |
| 35 | cache.Set(key, "second-value", time.Minute) |
| 36 | |
| 37 | got, ok := cache.Get(key) |
| 38 | assert.True(t, ok) |
| 39 | assert.Equal(t, "second-value", got, "Should return last set value") |
| 40 | }) |
| 41 | } |
| 42 | |
| 43 | func TestCache_Delete(t *testing.T) { |
| 44 | cache := createTestCache(t) |
nothing calls this directly
no test coverage detected