client: add test with multiple ignores in the config

Illustrates https://camlistore.org/r/2296

Fixes http://camlistore.org/issue/390

Change-Id: I8d98a938458239502617352f8eaf1a12f96e50d0
This commit is contained in:
mpl 2014-08-26 00:46:07 +02:00
parent f369c56a4b
commit 65fb60de32
1 changed files with 18 additions and 0 deletions

View File

@ -21,6 +21,24 @@ import (
"testing"
)
// this test demonstrates why http://camlistore.org/r/2296 was needed for
// matching to correctly work when the checker has more than one pattern of the
// same kind. Before the fix, this test would fail because the first
// isShellPatternMatch closure of the checker would not end up using the
// intended "*.jpg" pattern.
func TestIgnoreMultiPattern(t *testing.T) {
ignoredShellPattern := []string{
"*.jpg",
"*.png",
"*.gif",
}
ignoreChecker := newIgnoreChecker(ignoredShellPattern)
toIgnore := "/home/foo/Downloads/pony.jpg"
if ignoreChecker(toIgnore) != true {
t.Errorf("Failed to ignore %v with %q among multiple shell patterns in ignore list.", toIgnore, ignoredShellPattern[0])
}
}
func TestIsIgnoredFile(t *testing.T) {
old := osutilHomeDir
defer func() { osutilHomeDir = old }()