diff --git a/src/cmds/restic/integration_helpers_test.go b/src/cmds/restic/integration_helpers_test.go index ad6acc8a1..8c58028f6 100644 --- a/src/cmds/restic/integration_helpers_test.go +++ b/src/cmds/restic/integration_helpers_test.go @@ -9,6 +9,7 @@ import ( "runtime" "testing" + "restic/options" "restic/repository" . "restic/test" ) @@ -199,6 +200,7 @@ func withTestEnvironment(t testing.TB, f func(*testEnvironment, GlobalOptions)) password: TestPassword, stdout: os.Stdout, stderr: os.Stderr, + extended: make(options.Options), } // always overwrite global options diff --git a/src/cmds/restic/local_layout_test.go b/src/cmds/restic/local_layout_test.go new file mode 100644 index 000000000..eb6268e72 --- /dev/null +++ b/src/cmds/restic/local_layout_test.go @@ -0,0 +1,41 @@ +package main + +import ( + "path/filepath" + . "restic/test" + "testing" +) + +func TestRestoreLocalLayout(t *testing.T) { + withTestEnvironment(t, func(env *testEnvironment, gopts GlobalOptions) { + var tests = []struct { + filename string + layout string + }{ + {"repo-layout-cloud.tar.gz", ""}, + {"repo-layout-local.tar.gz", ""}, + {"repo-layout-s3-old.tar.gz", ""}, + {"repo-layout-cloud.tar.gz", "cloud"}, + {"repo-layout-local.tar.gz", "default"}, + {"repo-layout-s3-old.tar.gz", "s3"}, + } + + for _, test := range tests { + datafile := filepath.Join("..", "..", "restic", "backend", "testdata", test.filename) + + SetupTarTestFixture(t, env.base, datafile) + + gopts.extended["local.layout"] = test.layout + + // check the repo + testRunCheck(t, gopts) + + // restore latest snapshot + target := filepath.Join(env.base, "restore") + testRunRestoreLatest(t, gopts, target, nil, "") + + RemoveAll(t, filepath.Join(env.base, "repo")) + RemoveAll(t, target) + } + }) +}