restore: add dry-run support

This commit is contained in:
Michael Eischer
2024-05-31 20:57:28 +02:00
parent c47bf33884
commit 83351f42e3
4 changed files with 82 additions and 19 deletions

View File

@@ -83,6 +83,14 @@ func (p *printerMock) Finish(s restoreui.State, _ time.Duration) {
}
func TestRestorerProgressBar(t *testing.T) {
testRestorerProgressBar(t, false)
}
func TestRestorerProgressBarDryRun(t *testing.T) {
testRestorerProgressBar(t, true)
}
func testRestorerProgressBar(t *testing.T, dryRun bool) {
repo := repository.TestRepository(t)
sn, _ := saveSnapshot(t, repo, Snapshot{
@@ -99,7 +107,7 @@ func TestRestorerProgressBar(t *testing.T) {
mock := &printerMock{}
progress := restoreui.NewProgress(mock, 0)
res := NewRestorer(repo, sn, Options{Progress: progress})
res := NewRestorer(repo, sn, Options{Progress: progress, DryRun: dryRun})
res.SelectFilter = func(item string, dstpath string, node *restic.Node) (selectedForRestore bool, childMayBeSelected bool) {
return true, true
}