forked from TrueCloudLab/restic
Add integration test for layouts
This commit is contained in:
parent
95ab5adda1
commit
d1efdcd78e
2 changed files with 43 additions and 0 deletions
|
@ -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
|
||||
|
|
41
src/cmds/restic/local_layout_test.go
Normal file
41
src/cmds/restic/local_layout_test.go
Normal file
|
@ -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)
|
||||
}
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue