mirror of
https://github.com/octoleo/restic.git
synced 2024-11-26 23:06:32 +00:00
restore: test --dry-run plus --delete
This commit is contained in:
parent
aa8e18cf32
commit
868219aad1
@ -1214,6 +1214,32 @@ func TestRestoreDryRun(t *testing.T) {
|
|||||||
rtest.Assert(t, errors.Is(err, os.ErrNotExist), "expected no file to be created, got %v", err)
|
rtest.Assert(t, errors.Is(err, os.ErrNotExist), "expected no file to be created, got %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRestoreDryRunDelete(t *testing.T) {
|
||||||
|
snapshot := Snapshot{
|
||||||
|
Nodes: map[string]Node{
|
||||||
|
"foo": File{Data: "content: foo\n"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
repo := repository.TestRepository(t)
|
||||||
|
tempdir := filepath.Join(rtest.TempDir(t), "target")
|
||||||
|
tempfile := filepath.Join(tempdir, "existing")
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
rtest.OK(t, os.Mkdir(tempdir, 0o755))
|
||||||
|
f, err := os.Create(tempfile)
|
||||||
|
rtest.OK(t, err)
|
||||||
|
rtest.OK(t, f.Close())
|
||||||
|
|
||||||
|
sn, _ := saveSnapshot(t, repo, snapshot, noopGetGenericAttributes)
|
||||||
|
res := NewRestorer(repo, sn, Options{DryRun: true, Delete: true})
|
||||||
|
rtest.OK(t, res.RestoreTo(ctx, tempdir))
|
||||||
|
|
||||||
|
_, err = os.Stat(tempfile)
|
||||||
|
rtest.Assert(t, err == nil, "expected file to still exist, got error %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
func TestRestoreOverwriteDirectory(t *testing.T) {
|
func TestRestoreOverwriteDirectory(t *testing.T) {
|
||||||
saveSnapshotsAndOverwrite(t,
|
saveSnapshotsAndOverwrite(t,
|
||||||
Snapshot{
|
Snapshot{
|
||||||
|
Loading…
Reference in New Issue
Block a user