restic/cmd/restic/local_layout_test.go

42 lines
937 B
Go
Raw Normal View History

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) {
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)
env.gopts.extended["local.layout"] = test.layout
// check the repo
testRunCheck(t, env.gopts)
// restore latest snapshot
target := filepath.Join(env.base, "restore")
testRunRestoreLatest(t, env.gopts, target, nil, nil)
2017-10-02 13:06:39 +00:00
rtest.RemoveAll(t, filepath.Join(env.base, "repo"))
rtest.RemoveAll(t, target)
}
2017-04-02 18:33:24 +00:00
}