mirror of
https://github.com/octoleo/restic.git
synced 2024-11-29 16:23:59 +00:00
restorer: Add test for restore with include filter
This commit is contained in:
parent
67535e00a8
commit
4f6d2502f7
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user