mirror of
https://github.com/restic/restic.git
synced 2024-12-22 07:43:03 +00:00
filter: test some corner cases
This commit is contained in:
parent
0ae02f3030
commit
fdd3b14db3
1 changed files with 33 additions and 0 deletions
|
@ -244,6 +244,7 @@ var filterListTests = []struct {
|
|||
path string
|
||||
match 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},
|
||||
|
@ -279,6 +280,38 @@ func ExampleList() {
|
|||
// match: true
|
||||
}
|
||||
|
||||
func TestInvalidStrs(t *testing.T) {
|
||||
_, err := filter.Match("test", "")
|
||||
if err == nil {
|
||||
t.Error("Match accepted invalid path")
|
||||
}
|
||||
|
||||
_, err = filter.ChildMatch("test", "")
|
||||
if err == nil {
|
||||
t.Error("ChildMatch accepted invalid path")
|
||||
}
|
||||
|
||||
patterns := []string{"test"}
|
||||
_, _, err = filter.List(patterns, "")
|
||||
if err == nil {
|
||||
t.Error("List accepted invalid path")
|
||||
}
|
||||
}
|
||||
|
||||
func TestInvalidPattern(t *testing.T) {
|
||||
patterns := []string{"test/["}
|
||||
_, _, err := filter.List(patterns, "test/example")
|
||||
if err == nil {
|
||||
t.Error("List accepted invalid pattern")
|
||||
}
|
||||
|
||||
patterns = []string{"test/**/["}
|
||||
_, _, err = filter.List(patterns, "test/example")
|
||||
if err == nil {
|
||||
t.Error("List accepted invalid pattern")
|
||||
}
|
||||
}
|
||||
|
||||
func extractTestLines(t testing.TB) (lines []string) {
|
||||
f, err := os.Open("testdata/libreoffice.txt.bz2")
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue