MCPcopy Index your code
hub / github.com/kopia/kopia / TestSetLoggingPolicy

Function TestSetLoggingPolicy

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

Source from the content-addressed store, hash-verified

11)
12
13func TestSetLoggingPolicy(t *testing.T) {
14 e := testenv.NewCLITest(t, testenv.RepoFormatNotImportant, testenv.NewInProcRunner(t))
15 defer e.RunAndExpectSuccess(t, "repo", "disconnect")
16
17 e.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", e.RepoDir)
18
19 lines := e.RunAndExpectSuccess(t, "policy", "show", "--global")
20 lines = compressSpaces(lines)
21 require.Contains(t, lines, " Directory snapshotted: 5 (defined for this target)")
22 require.Contains(t, lines, " Directory ignored: 5 (defined for this target)")
23 require.Contains(t, lines, " Entry snapshotted: 0 (defined for this target)")
24 require.Contains(t, lines, " Entry ignored: 5 (defined for this target)")
25 require.Contains(t, lines, " Entry cache hit: 0 (defined for this target)")
26 require.Contains(t, lines, " Entry cache miss: 0 (defined for this target)")
27
28 // make some directory we'll be setting policy on
29 td := testutil.TempDirectory(t)
30
31 lines = e.RunAndExpectSuccess(t, "policy", "show", td)
32 lines = compressSpaces(lines)
33 require.Contains(t, lines, " Directory snapshotted: 5 inherited from (global)")
34 require.Contains(t, lines, " Directory ignored: 5 inherited from (global)")
35 require.Contains(t, lines, " Entry snapshotted: 0 inherited from (global)")
36 require.Contains(t, lines, " Entry ignored: 5 inherited from (global)")
37 require.Contains(t, lines, " Entry cache hit: 0 inherited from (global)")
38 require.Contains(t, lines, " Entry cache miss: 0 inherited from (global)")
39
40 e.RunAndExpectSuccess(t, "policy", "set", td,
41 "--log-dir-snapshotted=1",
42 "--log-dir-ignored=2",
43 "--log-entry-snapshotted=3",
44 "--log-entry-ignored=4",
45 "--log-entry-cache-hit=5",
46 "--log-entry-cache-miss=6")
47
48 lines = e.RunAndExpectSuccess(t, "policy", "show", td)
49 lines = compressSpaces(lines)
50 require.Contains(t, lines, " Directory snapshotted: 1 (defined for this target)")
51 require.Contains(t, lines, " Directory ignored: 2 (defined for this target)")
52 require.Contains(t, lines, " Entry snapshotted: 3 (defined for this target)")
53 require.Contains(t, lines, " Entry ignored: 4 (defined for this target)")
54 require.Contains(t, lines, " Entry cache hit: 5 (defined for this target)")
55 require.Contains(t, lines, " Entry cache miss: 6 (defined for this target)")
56
57 e.RunAndExpectSuccess(t, "policy", "set", td, "--log-entry-ignored=inherit")
58
59 lines = e.RunAndExpectSuccess(t, "policy", "show", td)
60 lines = compressSpaces(lines)
61 require.Contains(t, lines, " Entry ignored: 5 inherited from (global)")
62
63 e.RunAndExpectFailure(t, "policy", "set", td, "--log-dir-snapshotted=-1")
64 e.RunAndExpectFailure(t, "policy", "set", td, "--log-dir-ignored=11")
65 e.RunAndExpectFailure(t, "policy", "set", td, "--log-entry-snapshotted=xx")
66 e.RunAndExpectFailure(t, "policy", "set", td, "--log-entry-ignored=-1")
67 e.RunAndExpectFailure(t, "policy", "set", td, "--log-entry-cache-hit=-1")
68 e.RunAndExpectFailure(t, "policy", "set", td, "--log-entry-cache-miss=-1")
69}
70

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected