mirror of
https://github.com/restic/restic.git
synced 2025-06-12 01:58:28 +00:00
prune: fix not working option
This commit is contained in:
parent
3e58b15ace
commit
062cfc549d
@ -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,
|
||||
|
@ -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%",
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user