MCPcopy
hub / github.com/kopia/kopia / forgetContents

Function forgetContents

cli/command_snapshot_fix_test.go:367–386  ·  view source on GitHub ↗

forgetContents rewrites contents into a new blob and deletes the blob making index entries dangling.

(t *testing.T, env *testenv.CLITest, contentIDs ...string)

Source from the content-addressed store, hash-verified

365// forgetContents rewrites contents into a new blob and deletes the blob
366// making index entries dangling.
367func forgetContents(t *testing.T, env *testenv.CLITest, contentIDs ...string) {
368 t.Helper()
369
370 before := mustGetContentMap(t, env)
371
372 env.RunAndExpectSuccess(t, append([]string{"content", "rewrite", "--safety=none"}, contentIDs...)...)
373
374 after := mustGetContentMap(t, env)
375
376 var blobIDs []string
377
378 for _, cidStr := range contentIDs {
379 cid, err := content.ParseID(cidStr)
380 require.NoError(t, err)
381 require.NotEqual(t, before[cid].PackBlobID, after[cid].PackBlobID)
382 blobIDs = append(blobIDs, string(after[cid].PackBlobID))
383 }
384
385 env.RunAndExpectSuccess(t, append([]string{"blob", "rm"}, blobIDs...)...)
386}
387
388func mustGetContentMap(t *testing.T, env *testenv.CLITest) map[content.ID]content.Info {
389 t.Helper()

Callers 2

TestSnapshotVerifyFunction · 0.85
TestSnapshotFixFunction · 0.85

Calls 4

ParseIDFunction · 0.92
mustGetContentMapFunction · 0.85
HelperMethod · 0.80
RunAndExpectSuccessMethod · 0.65

Tested by

no test coverage detected