(t *testing.T)
| 240 | } |
| 241 | |
| 242 | func TestCacheFailureToOpen(t *testing.T) { |
| 243 | someError := errors.New("some error") |
| 244 | |
| 245 | cacheData := blobtesting.DataMap{} |
| 246 | cacheStorage := blobtesting.NewMapStorage(cacheData, nil, nil) |
| 247 | underlyingStorage := newUnderlyingStorageForContentCacheTesting(t) |
| 248 | faultyCache := blobtesting.NewFaultyStorage(cacheStorage) |
| 249 | faultyCache.AddFault(blobtesting.MethodGetMetadata).ErrorInstead(someError) |
| 250 | |
| 251 | // Will fail because of ListBlobs failure. |
| 252 | _, err := cache.NewContentCache(testlogging.Context(t), underlyingStorage, cache.Options{ |
| 253 | Storage: withoutTouchBlob{faultyCache}, |
| 254 | Sweep: cache.SweepSettings{MaxSizeBytes: 10000}, |
| 255 | }, nil) |
| 256 | require.Error(t, err) |
| 257 | require.ErrorContains(t, err, someError.Error()) |
| 258 | |
| 259 | // ListBlobs fails only once, next time it succeeds. |
| 260 | ctx := testlogging.Context(t) |
| 261 | |
| 262 | cc, err := cache.NewContentCache(ctx, underlyingStorage, cache.Options{ |
| 263 | Storage: withoutTouchBlob{faultyCache}, |
| 264 | Sweep: cache.SweepSettings{MaxSizeBytes: 10000}, |
| 265 | }, nil) |
| 266 | require.NoError(t, err) |
| 267 | |
| 268 | cc.Close(ctx) |
| 269 | } |
| 270 | |
| 271 | func TestCacheFailureToWrite(t *testing.T) { |
| 272 | someError := errors.New("some error") |
nothing calls this directly
no test coverage detected