MCPcopy
hub / github.com/kopia/kopia / TestPersistentLRUCache_Defaults

Function TestPersistentLRUCache_Defaults

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

Source from the content-addressed store, hash-verified

302}
303
304func TestPersistentLRUCache_Defaults(t *testing.T) {
305 cacheDir := testutil.TempDirectory(t)
306 ctx := testlogging.ContextWithLevel(t, testlogging.LevelInfo)
307
308 const maxSizeBytes = 1000
309
310 cs, err := cache.NewStorageOrNil(ctx, cacheDir, maxSizeBytes, "subdir")
311 require.NoError(t, err)
312
313 pc, err := cache.NewPersistentCache(ctx, "testing", cs, nil, cache.SweepSettings{
314 MaxSizeBytes: maxSizeBytes,
315 }, nil, clock.Now)
316 require.NoError(t, err)
317
318 defer pc.Close(ctx)
319
320 pc.Put(ctx, "key1", gather.FromSlice([]byte{1, 2, 3}))
321 verifyCached(ctx, t, pc, "key1", []byte{1, 2, 3})
322}
323
324func verifyCached(ctx context.Context, t *testing.T, pc *cache.PersistentCache, key string, want []byte) {
325 t.Helper()

Callers

nothing calls this directly

Calls 8

CloseMethod · 0.95
PutMethod · 0.95
TempDirectoryFunction · 0.92
ContextWithLevelFunction · 0.92
NewStorageOrNilFunction · 0.92
NewPersistentCacheFunction · 0.92
FromSliceFunction · 0.92
verifyCachedFunction · 0.85

Tested by

no test coverage detected