MCPcopy
hub / github.com/kopia/kopia / TestCacheSet

Function TestCacheSet

cli/command_cache_set_test.go:13–49  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func TestCacheSet(t *testing.T) {
14 env := testenv.NewCLITest(t, testenv.RepoFormatNotImportant, testenv.NewInProcRunner(t))
15
16 env.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", env.RepoDir)
17
18 // no changes
19 env.RunAndExpectFailure(t, "cache", "set")
20
21 ncd := testutil.TempDirectory(t)
22
23 env.RunAndExpectSuccess(t,
24 "cache", "set",
25 "--cache-directory", ncd,
26 "--max-list-cache-duration=55s",
27 )
28
29 env.RunAndExpectSuccess(t,
30 "cache", "set",
31 "--cache-directory", ncd,
32 "--content-cache-size-mb=33",
33 "--content-cache-size-limit-mb=331",
34 "--metadata-cache-size-mb=44",
35 "--metadata-cache-size-limit-mb=441",
36 )
37
38 out := env.RunAndExpectSuccess(t, "cache", "info")
39 require.Contains(t, mustGetLineContaining(t, out, "33 MB"), ncd)
40 require.Contains(t, mustGetLineContaining(t, out, "soft limit: 33 MB"), "contents")
41 require.Contains(t, mustGetLineContaining(t, out, "hard limit: 331 MB"), "contents")
42 require.Contains(t, mustGetLineContaining(t, out, "min sweep age: 10m0s"), "contents")
43
44 require.Contains(t, mustGetLineContaining(t, out, "soft limit: 44 MB"), "metadata")
45 require.Contains(t, mustGetLineContaining(t, out, "hard limit: 441 MB"), "metadata")
46 require.Contains(t, mustGetLineContaining(t, out, "min sweep age: 24h0m0s"), "metadata")
47
48 require.Contains(t, mustGetLineContaining(t, out, "55s"), "blob-list")
49}
50
51func mustGetLineContaining(t *testing.T, lines []string, containing string) string {
52 t.Helper()

Callers

nothing calls this directly

Calls 7

RunAndExpectSuccessMethod · 0.95
RunAndExpectFailureMethod · 0.95
NewCLITestFunction · 0.92
NewInProcRunnerFunction · 0.92
TempDirectoryFunction · 0.92
mustGetLineContainingFunction · 0.85
ContainsMethod · 0.45

Tested by

no test coverage detected