MCPcopy
hub / github.com/kopia/kopia / TestSetUploadPolicy

Function TestSetUploadPolicy

cli/command_policy_set_upload_test.go:12–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestSetUploadPolicy(t *testing.T) {
13 e := testenv.NewCLITest(t, testenv.RepoFormatNotImportant, testenv.NewInProcRunner(t))
14 defer e.RunAndExpectSuccess(t, "repo", "disconnect")
15
16 e.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", e.RepoDir)
17
18 lines := e.RunAndExpectSuccess(t, "policy", "show", "--global")
19 lines = compressSpaces(lines)
20 require.Contains(t, lines, " Max parallel snapshots (server/UI): 1 (defined for this target)")
21 require.Contains(t, lines, " Max parallel file reads: - (defined for this target)")
22 require.Contains(t, lines, " Parallel upload above size: 2.1 GB (defined for this target)")
23
24 // make some directory we'll be setting policy on
25 td := testutil.TempDirectory(t)
26
27 lines = e.RunAndExpectSuccess(t, "policy", "show", td)
28 lines = compressSpaces(lines)
29 require.Contains(t, lines, " Max parallel snapshots (server/UI): 1 inherited from (global)")
30 require.Contains(t, lines, " Max parallel file reads: - inherited from (global)")
31 require.Contains(t, lines, " Parallel upload above size: 2.1 GB inherited from (global)")
32
33 e.RunAndExpectSuccess(t, "policy", "set", "--global", "--max-parallel-snapshots=7", "--max-parallel-file-reads=33", "--parallel-upload-above-size-mib=4096")
34
35 lines = e.RunAndExpectSuccess(t, "policy", "show", td)
36 lines = compressSpaces(lines)
37
38 require.Contains(t, lines, " Max parallel snapshots (server/UI): 7 inherited from (global)")
39 require.Contains(t, lines, " Max parallel file reads: 33 inherited from (global)")
40 require.Contains(t, lines, " Parallel upload above size: 4.3 GB inherited from (global)")
41
42 e.RunAndExpectSuccess(t, "policy", "set", "--global", "--max-parallel-snapshots=default", "--max-parallel-file-reads=default", "--parallel-upload-above-size-mib=default")
43
44 lines = e.RunAndExpectSuccess(t, "policy", "show", td)
45 lines = compressSpaces(lines)
46
47 require.Contains(t, lines, " Max parallel snapshots (server/UI): 1 inherited from (global)")
48 require.Contains(t, lines, " Max parallel file reads: - inherited from (global)")
49 require.Contains(t, lines, " Parallel upload above size: 2.1 GB inherited from (global)")
50}

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected