mirror of https://github.com/restic/restic.git
rewrite integration tests: add tests for conflicting options.
Conflicting options will stop normal processing of the `restic rewrite` command.
This commit is contained in:
parent
04c9b35481
commit
2d0d340ade
|
@ -237,7 +237,7 @@ func TestRewriteEmptyDirectory(t *testing.T) {
|
||||||
count++
|
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
|
// get snapshot summary and find this 1 directory
|
||||||
_, repo, unlock, err := openWithExclusiveLock(context.TODO(), env.gopts, false)
|
_, 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)
|
"there should be 0 files in the snapshot, but there are %d files", sn.Summary.TotalFilesProcessed)
|
||||||
unlock()
|
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!")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue