mirror of
https://github.com/restic/restic.git
synced 2024-12-24 16:54:00 +00:00
restorer: Add test for restore with include filter
This commit is contained in:
parent
67535e00a8
commit
4f6d2502f7
1 changed files with 31 additions and 0 deletions
|
@ -134,6 +134,7 @@ func TestRestorer(t *testing.T) {
|
||||||
Files map[string]string
|
Files map[string]string
|
||||||
ErrorsMust map[string]string
|
ErrorsMust map[string]string
|
||||||
ErrorsMay map[string]string
|
ErrorsMay map[string]string
|
||||||
|
Select func(item string, dstpath string, node *restic.Node) (selectForRestore bool, childMayBeSelected bool)
|
||||||
}{
|
}{
|
||||||
// valid test cases
|
// valid test cases
|
||||||
{
|
{
|
||||||
|
@ -212,6 +213,31 @@ func TestRestorer(t *testing.T) {
|
||||||
"topfile": "top-level file",
|
"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
|
// test cases with invalid/constructed names
|
||||||
{
|
{
|
||||||
|
@ -293,6 +319,11 @@ func TestRestorer(t *testing.T) {
|
||||||
item, dstpath, tempdir)
|
item, dstpath, tempdir)
|
||||||
return false, false
|
return false, false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if test.Select != nil {
|
||||||
|
return test.Select(item, dstpath, node)
|
||||||
|
}
|
||||||
|
|
||||||
return true, true
|
return true, true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue