rewrite integration tests: add tests for conflicting options.

Conflicting options will stop normal processing of the `restic rewrite` command.
This commit is contained in:
Winfried Plappert 2025-02-19 21:35:54 +00:00
parent 04c9b35481
commit 2d0d340ade
1 changed files with 22 additions and 1 deletions

View File

@ -237,7 +237,7 @@ func TestRewriteEmptyDirectory(t *testing.T) {
count++
}
}
rtest.Assert(t, count == 1, "there should be 1 empty directory in the snapshot, but there are %d output lines", count)
rtest.Assert(t, count == 1, "there should be 1 empty directory in the snapshot, but there are %d snapshots", count)
// get snapshot summary and find this 1 directory
_, repo, unlock, err := openWithExclusiveLock(context.TODO(), env.gopts, false)
@ -251,3 +251,24 @@ func TestRewriteEmptyDirectory(t *testing.T) {
"there should be 0 files in the snapshot, but there are %d files", sn.Summary.TotalFilesProcessed)
unlock()
}
func TestRewriteConflictingOptions(t *testing.T) {
env, cleanup := withTestEnvironment(t)
defer cleanup()
createBasicRewriteRepo(t, env)
err := runRewrite(context.TODO(), RewriteOptions{}, env.gopts, []string{"latest"})
rtest.Assert(t, err != nil, "Nothing to do: no includes/excludes provided and no new metadata provided")
err = runRewrite(context.TODO(), RewriteOptions{
IncludePatternOptions: filter.IncludePatternOptions{Includes: []string{"JohannSebastianBach"}},
ExcludePatternOptions: filter.ExcludePatternOptions{Excludes: []string{"WolfgangAmadeusMozart"}},
}, env.gopts, []string{"latest"})
rtest.Assert(t, err != nil, "You cannot specify include and exclude options simultaneously!")
err = runRewrite(context.TODO(), RewriteOptions{
SnapshotSummary: true,
IncludePatternOptions: filter.IncludePatternOptions{Includes: []string{"JohannSebastianBach"}},
}, env.gopts, []string{"latest"})
rtest.Assert(t, err != nil, "You cannot specify include or exclude options together with --snapshot-summary!")
}