mirror of
https://github.com/octoleo/restic.git
synced 2024-11-25 14:17:42 +00:00
filter: explicitly test separate ListWithChild function
This commit is contained in:
parent
bcc3bddcf4
commit
54a124de3b
@ -240,21 +240,22 @@ func ExampleMatch_wildcards() {
|
||||
}
|
||||
|
||||
var filterListTests = []struct {
|
||||
patterns []string
|
||||
path string
|
||||
match bool
|
||||
patterns []string
|
||||
path string
|
||||
match bool
|
||||
childMatch bool
|
||||
}{
|
||||
{[]string{}, "/foo/bar/test.go", false},
|
||||
{[]string{"*.go"}, "/foo/bar/test.go", true},
|
||||
{[]string{"*.c"}, "/foo/bar/test.go", false},
|
||||
{[]string{"*.go", "*.c"}, "/foo/bar/test.go", true},
|
||||
{[]string{"*"}, "/foo/bar/test.go", true},
|
||||
{[]string{"x"}, "/foo/bar/test.go", false},
|
||||
{[]string{"?"}, "/foo/bar/test.go", false},
|
||||
{[]string{"?", "x"}, "/foo/bar/x", true},
|
||||
{[]string{"/*/*/bar/test.*"}, "/foo/bar/test.go", false},
|
||||
{[]string{"/*/*/bar/test.*", "*.go"}, "/foo/bar/test.go", true},
|
||||
{[]string{"", "*.c"}, "/foo/bar/test.go", false},
|
||||
{[]string{}, "/foo/bar/test.go", false, false},
|
||||
{[]string{"*.go"}, "/foo/bar/test.go", true, true},
|
||||
{[]string{"*.c"}, "/foo/bar/test.go", false, true},
|
||||
{[]string{"*.go", "*.c"}, "/foo/bar/test.go", true, true},
|
||||
{[]string{"*"}, "/foo/bar/test.go", true, true},
|
||||
{[]string{"x"}, "/foo/bar/test.go", false, true},
|
||||
{[]string{"?"}, "/foo/bar/test.go", false, true},
|
||||
{[]string{"?", "x"}, "/foo/bar/x", true, true},
|
||||
{[]string{"/*/*/bar/test.*"}, "/foo/bar/test.go", false, false},
|
||||
{[]string{"/*/*/bar/test.*", "*.go"}, "/foo/bar/test.go", true, true},
|
||||
{[]string{"", "*.c"}, "/foo/bar/test.go", false, true},
|
||||
}
|
||||
|
||||
func TestList(t *testing.T) {
|
||||
@ -268,9 +269,21 @@ func TestList(t *testing.T) {
|
||||
}
|
||||
|
||||
if match != test.match {
|
||||
t.Errorf("test %d: filter.MatchList(%q, %q): expected %v, got %v",
|
||||
t.Errorf("test %d: filter.List(%q, %q): expected %v, got %v",
|
||||
i, test.patterns, test.path, test.match, match)
|
||||
}
|
||||
|
||||
match, childMatch, err := filter.ListWithChild(patterns, test.path)
|
||||
if err != nil {
|
||||
t.Errorf("test %d failed: expected no error for patterns %q, but error returned: %v",
|
||||
i, test.patterns, err)
|
||||
continue
|
||||
}
|
||||
|
||||
if match != test.match || childMatch != test.childMatch {
|
||||
t.Errorf("test %d: filter.ListWithChild(%q, %q): expected %v, %v, got %v, %v",
|
||||
i, test.patterns, test.path, test.match, test.childMatch, match, childMatch)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user