Skip to content

Commit

Permalink
rewrite: add minimal test
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelEischer committed Sep 10, 2022
1 parent 46bdf40 commit 3d7d495
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions cmd/restic/integration_rewrite_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package main

import (
"path/filepath"
"testing"

rtest "github.com/restic/restic/internal/test"
)

func testRunRewriteExclude(t testing.TB, gopts GlobalOptions, excludes []string) {
opts := RewriteOptions{
excludePatternOptions: excludePatternOptions{
Excludes: excludes,
},
}

rtest.OK(t, runRewrite(opts, gopts, nil))
}

func TestRewrite(t *testing.T) {
env, cleanup := withTestEnvironment(t)
defer cleanup()

testSetupBackupData(t, env)

// create backup
testRunBackup(t, filepath.Dir(env.testdata), []string{"testdata"}, BackupOptions{}, env.gopts)
snapshotIDs := testRunList(t, "snapshots", env.gopts)
rtest.Assert(t, len(snapshotIDs) == 1, "expected one snapshot, got %v", snapshotIDs)
testRunCheck(t, env.gopts)

// exclude some data
testRunRewriteExclude(t, env.gopts, []string{"3"})
snapshotIDs = testRunList(t, "snapshots", env.gopts)
rtest.Assert(t, len(snapshotIDs) == 2, "expected two snapshots, got %v", snapshotIDs)
testRunCheck(t, env.gopts)
}

0 comments on commit 3d7d495

Please sign in to comment.