MCPcopy
hub / github.com/kopia/kopia / TestPersistentLRUCacheNil

Function TestPersistentLRUCacheNil

internal/cache/persistent_lru_cache_test.go:279–302  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

277}
278
279func TestPersistentLRUCacheNil(t *testing.T) {
280 ctx := testlogging.ContextWithLevel(t, testlogging.LevelInfo)
281
282 var pc *cache.PersistentCache
283
284 // no-op
285 pc.Close(ctx)
286 pc.Put(ctx, "key", gather.FromSlice([]byte{1, 2, 3}))
287 verifyNotCached(ctx, t, pc, "key")
288
289 var tmp gather.WriteBuffer
290 defer tmp.Close()
291
292 called := false
293
294 dummyError := errors.New("dummy error")
295
296 require.ErrorIs(t, pc.GetOrLoad(ctx, "key", func(output *gather.WriteBuffer) error {
297 called = true
298 return dummyError
299 }, &tmp), dummyError)
300
301 require.True(t, called)
302}
303
304func TestPersistentLRUCache_Defaults(t *testing.T) {
305 cacheDir := testutil.TempDirectory(t)

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
PutMethod · 0.95
CloseMethod · 0.95
GetOrLoadMethod · 0.95
ContextWithLevelFunction · 0.92
FromSliceFunction · 0.92
verifyNotCachedFunction · 0.85

Tested by

no test coverage detected