diff --git a/cmd/restic/cmd_prune.go b/cmd/restic/cmd_prune.go index 65833c689..ff43d83c0 100644 --- a/cmd/restic/cmd_prune.go +++ b/cmd/restic/cmd_prune.go @@ -207,6 +207,7 @@ func runPruneWithRepo(ctx context.Context, opts PruneOptions, gopts GlobalOption MaxUnusedBytes: opts.maxUnusedBytes, MaxRepackBytes: opts.MaxRepackBytes, + SmallPackBytes: opts.SmallPackBytes, RepackCacheableOnly: opts.RepackCacheableOnly, RepackSmall: opts.RepackSmall, diff --git a/cmd/restic/cmd_prune_integration_test.go b/cmd/restic/cmd_prune_integration_test.go index 0561f8243..9de2e0b8d 100644 --- a/cmd/restic/cmd_prune_integration_test.go +++ b/cmd/restic/cmd_prune_integration_test.go @@ -13,14 +13,25 @@ import ( ) func testRunPrune(t testing.TB, gopts GlobalOptions, opts PruneOptions) { + t.Helper() + rtest.OK(t, testRunPruneOutput(gopts, opts)) +} + +func testRunPruneMustFail(t testing.TB, gopts GlobalOptions, opts PruneOptions) { + t.Helper() + err := testRunPruneOutput(gopts, opts) + rtest.Assert(t, err != nil, "expected non nil error") +} + +func testRunPruneOutput(gopts GlobalOptions, opts PruneOptions) error { oldHook := gopts.backendTestHook gopts.backendTestHook = func(r backend.Backend) (backend.Backend, error) { return newListOnceBackend(r), nil } defer func() { gopts.backendTestHook = oldHook }() - rtest.OK(t, withTermStatus(gopts, func(ctx context.Context, term *termstatus.Terminal) error { + return withTermStatus(gopts, func(ctx context.Context, term *termstatus.Terminal) error { return runPrune(context.TODO(), opts, gopts, term) - })) + }) } func TestPrune(t *testing.T) { @@ -237,3 +248,20 @@ func testEdgeCaseRepo(t *testing.T, tarfile string, optionsCheck CheckOptions, o "prune should have reported an error") } } + +func TestPruneRepackSmallerThanSmoke(t *testing.T) { + env, cleanup := withTestEnvironment(t) + defer cleanup() + + // the implementation is already unit tested, so just check that + // the setting reaches its goal + createPrunableRepo(t, env) + testRunPrune(t, env.gopts, PruneOptions{ + SmallPackSize: "4M", + MaxUnused: "5%", + }) + testRunPruneMustFail(t, env.gopts, PruneOptions{ + SmallPackSize: "500M", + MaxUnused: "5%", + }) +}