(t *testing.T)
| 304 | } |
| 305 | |
| 306 | func TestCacheFailureToRead(t *testing.T) { |
| 307 | someError := errors.New("some error") |
| 308 | |
| 309 | cacheData := blobtesting.DataMap{} |
| 310 | cacheStorage := blobtesting.NewMapStorage(cacheData, nil, nil) |
| 311 | underlyingStorage := newUnderlyingStorageForContentCacheTesting(t) |
| 312 | faultyCache := blobtesting.NewFaultyStorage(cacheStorage) |
| 313 | |
| 314 | cc, err := cache.NewContentCache(testlogging.Context(t), underlyingStorage, cache.Options{ |
| 315 | Storage: withoutTouchBlob{faultyCache}, |
| 316 | Sweep: cache.SweepSettings{MaxSizeBytes: 10000}, |
| 317 | }, nil) |
| 318 | require.NoError(t, err) |
| 319 | |
| 320 | ctx := testlogging.Context(t) |
| 321 | |
| 322 | defer cc.Close(ctx) |
| 323 | |
| 324 | faultyCache.AddFault(blobtesting.MethodGetBlob).ErrorInstead(someError).Repeat(100) |
| 325 | |
| 326 | var v gather.WriteBuffer |
| 327 | defer v.Close() |
| 328 | |
| 329 | for range 2 { |
| 330 | require.NoError(t, cc.GetContent(ctx, "aa", "content-1", 0, 3, &v)) |
| 331 | |
| 332 | got, want := v.ToByteSlice(), []byte{1, 2, 3} |
| 333 | assert.Equal(t, want, got, "unexpected value retrieved from cache") |
| 334 | } |
| 335 | } |
| 336 | |
| 337 | func verifyStorageContentList(t *testing.T, st cache.Storage, expectedContents ...blob.ID) { |
| 338 | t.Helper() |
nothing calls this directly
no test coverage detected