forked from TrueCloudLab/restic
rewrite: add minimal test
This commit is contained in:
parent
375a3db64d
commit
b044649118
1 changed files with 38 additions and 0 deletions
38
cmd/restic/integration_rewrite_test.go
Normal file
38
cmd/restic/integration_rewrite_test.go
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"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(context.TODO(), 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)
|
||||||
|
}
|
Loading…
Reference in a new issue