MCPcopy
hub / github.com/kopia/kopia / TestContentVerify

Method TestContentVerify

cli/command_content_verify_test.go:16–40  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func (s *formatSpecificTestSuite) TestContentVerify(t *testing.T) {
17 env := testenv.NewCLITest(t, s.formatFlags, testenv.NewInProcRunner(t))
18
19 dir := testutil.TempDirectory(t)
20 require.NoError(t, os.WriteFile(filepath.Join(dir, "file1.txt"), bytes.Repeat([]byte{1, 2, 3, 4, 5}, 15000), 0o600))
21
22 env.RunAndExpectSuccess(t, "repo", "create", "filesystem", "--path", env.RepoDir)
23 env.RunAndExpectSuccess(t, "content", "verify")
24 env.RunAndExpectSuccess(t, "snapshot", "create", dir)
25 env.RunAndExpectSuccess(t, "content", "verify", "--download-percent=30")
26
27 // delete one of 'p' blobs.
28 blobIDToDelete := strings.Split(env.RunAndExpectSuccess(t, "blob", "list", "--prefix=p")[0], " ")[0]
29 blobList := env.RunAndExpectSuccess(t, "blob", "list")
30 t.Logf("blob list: %v", strings.Join(blobList, "\n"))
31 env.RunAndExpectSuccess(t, "blob", "delete", blobIDToDelete)
32
33 _, verifyStderr, err := env.Run(t, true, "content", "verify")
34 require.Error(t, err)
35
36 // this fails if not found
37 mustGetLineContaining(t, verifyStderr, "missing blob "+blobIDToDelete)
38
39 env.RunAndExpectFailure(t, "content", "verify", "--full")
40}

Callers

nothing calls this directly

Calls 11

RunAndExpectSuccessMethod · 0.95
RunMethod · 0.95
RunAndExpectFailureMethod · 0.95
NewCLITestFunction · 0.92
NewInProcRunnerFunction · 0.92
TempDirectoryFunction · 0.92
mustGetLineContainingFunction · 0.85
RepeatMethod · 0.80
LogfMethod · 0.80
WriteFileMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected