(t *testing.T)
| 269 | } |
| 270 | |
| 271 | func TestCacheFailureToWrite(t *testing.T) { |
| 272 | someError := errors.New("some error") |
| 273 | |
| 274 | cacheData := blobtesting.DataMap{} |
| 275 | cacheStorage := blobtesting.NewMapStorage(cacheData, nil, nil) |
| 276 | underlyingStorage := newUnderlyingStorageForContentCacheTesting(t) |
| 277 | faultyCache := blobtesting.NewFaultyStorage(cacheStorage) |
| 278 | |
| 279 | cc, err := cache.NewContentCache(testlogging.Context(t), underlyingStorage, cache.Options{ |
| 280 | Storage: withoutTouchBlob{faultyCache}, |
| 281 | Sweep: cache.SweepSettings{MaxSizeBytes: 10000}, |
| 282 | }, nil) |
| 283 | require.NoError(t, err) |
| 284 | |
| 285 | ctx := testlogging.Context(t) |
| 286 | |
| 287 | defer cc.Close(ctx) |
| 288 | |
| 289 | faultyCache.AddFault(blobtesting.MethodPutBlob).ErrorInstead(someError) |
| 290 | |
| 291 | var v gather.WriteBuffer |
| 292 | defer v.Close() |
| 293 | |
| 294 | err = cc.GetContent(ctx, "aa", "content-1", 0, 3, &v) |
| 295 | require.NoError(t, err, "write failure wasn't ignored") |
| 296 | |
| 297 | got, want := v.ToByteSlice(), []byte{1, 2, 3} |
| 298 | require.Equal(t, want, got, "unexpected value retrieved from cache") |
| 299 | |
| 300 | all, err := blob.ListAllBlobs(ctx, cacheStorage, "") |
| 301 | require.NoError(t, err, "error listing cache") |
| 302 | |
| 303 | require.Empty(t, all, "invalid test - cache was written") |
| 304 | } |
| 305 | |
| 306 | func TestCacheFailureToRead(t *testing.T) { |
| 307 | someError := errors.New("some error") |
nothing calls this directly
no test coverage detected