summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorAlexander Neumann <alexander@bumpern.de>2015-11-08 22:21:08 +0100
committerAlexander Neumann <alexander@bumpern.de>2015-11-08 22:21:08 +0100
commit2e6eee991d2c59e8189c4ef1d816eca0535d2b3b (patch)
tree7f1217b94fe2aaae9e0ee2a5ae97f527f3cf83d5 /cmd
parentc59b12c93957ef0539b1c6ba9ab157be291272c5 (diff)
Add test for optimize command with old indexes
Diffstat (limited to 'cmd')
-rw-r--r--cmd/restic/integration_test.go37
1 files changed, 28 insertions, 9 deletions
diff --git a/cmd/restic/integration_test.go b/cmd/restic/integration_test.go
index 5c5a196d1..2fafee92f 100644
--- a/cmd/restic/integration_test.go
+++ b/cmd/restic/integration_test.go
@@ -699,16 +699,35 @@ func TestRebuildIndexAlwaysFull(t *testing.T) {
TestRebuildIndex(t)
}
+var optimizeTests = []struct {
+ testFilename string
+ snapshotID string
+}{
+ {
+ filepath.Join("..", "..", "checker", "testdata", "checker-test-repo.tar.gz"),
+ "a13c11e582b77a693dd75ab4e3a3ba96538a056594a4b9076e4cacebe6e06d43",
+ },
+ {
+ filepath.Join("..", "..", "repository", "testdata", "old-index-repo.tar.gz"),
+ "",
+ },
+}
+
func TestOptimizeRemoveUnusedBlobs(t *testing.T) {
- withTestEnvironment(t, func(env *testEnvironment, global GlobalOptions) {
- datafile := filepath.Join("..", "..", "checker", "testdata", "checker-test-repo.tar.gz")
- SetupTarTestFixture(t, env.base, datafile)
+ for i, test := range optimizeTests {
+ withTestEnvironment(t, func(env *testEnvironment, global GlobalOptions) {
+ SetupTarTestFixture(t, env.base, test.testFilename)
- // snapshotIDs := cmdList(t, global, "snapshots")
- // t.Logf("snapshots: %v", snapshotIDs)
+ if test.snapshotID != "" {
+ OK(t, os.Remove(filepath.Join(env.repo, "snapshots", test.snapshotID)))
+ }
- OK(t, os.Remove(filepath.Join(env.repo, "snapshots", "a13c11e582b77a693dd75ab4e3a3ba96538a056594a4b9076e4cacebe6e06d43")))
- cmdOptimize(t, global)
- cmdCheck(t, global)
- })
+ cmdOptimize(t, global)
+ output := cmdCheckOutput(t, global)
+
+ if len(output) > 0 {
+ t.Errorf("expected no output for check in test %d, got:\n%v", i, output)
+ }
+ })
+ }
}