(t *testing.T)
| 11 | ) |
| 12 | |
| 13 | func 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 | |
| 51 | func mustGetLineContaining(t *testing.T, lines []string, containing string) string { |
| 52 | t.Helper() |
nothing calls this directly
no test coverage detected