2017-04-02 18:33:24 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
2017-07-23 12:21:03 +00:00
|
|
|
|
2017-10-02 13:06:39 +00:00
|
|
|
rtest "github.com/restic/restic/internal/test"
|
2017-04-02 18:33:24 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestRestoreLocalLayout(t *testing.T) {
|
2017-07-24 19:25:49 +00:00
|
|
|
env, cleanup := withTestEnvironment(t)
|
|
|
|
defer cleanup()
|
|
|
|
|
|
|
|
var tests = []struct {
|
|
|
|
filename string
|
|
|
|
layout string
|
|
|
|
}{
|
|
|
|
{"repo-layout-default.tar.gz", ""},
|
|
|
|
{"repo-layout-s3legacy.tar.gz", ""},
|
|
|
|
{"repo-layout-default.tar.gz", "default"},
|
|
|
|
{"repo-layout-s3legacy.tar.gz", "s3legacy"},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, test := range tests {
|
|
|
|
datafile := filepath.Join("..", "..", "internal", "backend", "testdata", test.filename)
|
|
|
|
|
2017-10-02 13:06:39 +00:00
|
|
|
rtest.SetupTarTestFixture(t, env.base, datafile)
|
2017-07-24 19:25:49 +00:00
|
|
|
|
|
|
|
env.gopts.extended["local.layout"] = test.layout
|
|
|
|
|
|
|
|
// check the repo
|
|
|
|
testRunCheck(t, env.gopts)
|
|
|
|
|
|
|
|
// restore latest snapshot
|
|
|
|
target := filepath.Join(env.base, "restore")
|
2020-02-26 21:17:59 +00:00
|
|
|
testRunRestoreLatest(t, env.gopts, target, nil, nil)
|
2017-07-24 19:25:49 +00:00
|
|
|
|
2017-10-02 13:06:39 +00:00
|
|
|
rtest.RemoveAll(t, filepath.Join(env.base, "repo"))
|
|
|
|
rtest.RemoveAll(t, target)
|
2017-07-24 19:25:49 +00:00
|
|
|
}
|
2017-04-02 18:33:24 +00:00
|
|
|
}
|