MCPcopy
hub / github.com/kopia/kopia / TestCacheFailureToOpen

Function TestCacheFailureToOpen

internal/cache/content_cache_test.go:242–269  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

240}
241
242func 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
271func TestCacheFailureToWrite(t *testing.T) {
272 someError := errors.New("some error")

Callers

nothing calls this directly

Calls 9

CloseMethod · 0.95
NewMapStorageFunction · 0.92
NewFaultyStorageFunction · 0.92
NewContentCacheFunction · 0.92
ContextFunction · 0.92
ErrorInsteadMethod · 0.80
AddFaultMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected