mirror of
https://github.com/restic/restic.git
synced 2024-12-25 17:27:25 +00:00
Add test for rejectByPattern
This commit is contained in:
parent
47ddd34266
commit
0b2947dedb
1 changed files with 27 additions and 0 deletions
|
@ -8,6 +8,33 @@ import (
|
||||||
"github.com/restic/restic/internal/test"
|
"github.com/restic/restic/internal/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestRejectByPattern(t *testing.T) {
|
||||||
|
var tests = []struct {
|
||||||
|
filename string
|
||||||
|
reject bool
|
||||||
|
}{
|
||||||
|
{filename: "/home/user/foo.go", reject: true},
|
||||||
|
{filename: "/home/user/foo.c", reject: false},
|
||||||
|
{filename: "/home/user/foobar", reject: false},
|
||||||
|
{filename: "/home/user/foobar/x", reject: true},
|
||||||
|
{filename: "/home/user/README", reject: false},
|
||||||
|
{filename: "/home/user/README.md", reject: true},
|
||||||
|
}
|
||||||
|
|
||||||
|
patterns := []string{"*.go", "README.md", "/home/user/foobar/*"}
|
||||||
|
|
||||||
|
for _, tc := range tests {
|
||||||
|
t.Run("", func(t *testing.T) {
|
||||||
|
reject := rejectByPattern(patterns)
|
||||||
|
res := reject(tc.filename, nil)
|
||||||
|
if res != tc.reject {
|
||||||
|
t.Fatalf("wrong result for filename %v: want %v, got %v",
|
||||||
|
tc.filename, tc.reject, res)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestIsExcludedByFile(t *testing.T) {
|
func TestIsExcludedByFile(t *testing.T) {
|
||||||
const (
|
const (
|
||||||
tagFilename = "CACHEDIR.TAG"
|
tagFilename = "CACHEDIR.TAG"
|
||||||
|
|
Loading…
Reference in a new issue