2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-26 06:46:34 +00:00

restorer: Add test for restore with include filter

This commit is contained in:
Alexander Neumann 2018-07-21 14:06:19 +02:00
parent 67535e00a8
commit 4f6d2502f7

View File

@ -134,6 +134,7 @@ func TestRestorer(t *testing.T) {
Files map[string]string
ErrorsMust map[string]string
ErrorsMay map[string]string
Select func(item string, dstpath string, node *restic.Node) (selectForRestore bool, childMayBeSelected bool)
}{
// valid test cases
{
@ -212,6 +213,31 @@ func TestRestorer(t *testing.T) {
"topfile": "top-level file",
},
},
{
Snapshot: Snapshot{
Nodes: map[string]Node{
"dir": Dir{
Nodes: map[string]Node{
"file": File{"content: file\n"},
},
},
},
},
Files: map[string]string{
"dir/file": "content: file\n",
},
Select: func(item, dstpath string, node *restic.Node) (selectedForRestore bool, childMayBeSelected bool) {
switch item {
case filepath.FromSlash("/dir"):
childMayBeSelected = true
case filepath.FromSlash("/dir/file"):
selectedForRestore = true
childMayBeSelected = true
}
return selectedForRestore, childMayBeSelected
},
},
// test cases with invalid/constructed names
{
@ -293,6 +319,11 @@ func TestRestorer(t *testing.T) {
item, dstpath, tempdir)
return false, false
}
if test.Select != nil {
return test.Select(item, dstpath, node)
}
return true, true
}