MCPcopy
hub / github.com/kopia/kopia / TestDiskContentCache

Function TestDiskContentCache

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

Source from the content-addressed store, hash-verified

150}
151
152func TestDiskContentCache(t *testing.T) {
153 ctx := testlogging.Context(t)
154
155 tmpDir := testutil.TempDirectory(t)
156
157 const maxBytes = 10000
158
159 cacheStorage, err := cache.NewStorageOrNil(ctx, tmpDir, maxBytes, "contents")
160 require.NoError(t, err)
161
162 cc, err := cache.NewContentCache(ctx, newUnderlyingStorageForContentCacheTesting(t), cache.Options{
163 Storage: cacheStorage,
164 Sweep: cache.SweepSettings{
165 MaxSizeBytes: maxBytes,
166 },
167 }, nil)
168 require.NoError(t, err)
169
170 defer cc.Close(ctx)
171
172 verifyContentCache(t, cc, cacheStorage)
173}
174
175func verifyContentCache(t *testing.T, cc cache.ContentCache, cacheStorage cache.Storage) {
176 t.Helper()

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
ContextFunction · 0.92
TempDirectoryFunction · 0.92
NewStorageOrNilFunction · 0.92
NewContentCacheFunction · 0.92
verifyContentCacheFunction · 0.85

Tested by

no test coverage detected