From 65fb60de32c3c176bfcc8aed3626124639c2b259 Mon Sep 17 00:00:00 2001 From: mpl Date: Tue, 26 Aug 2014 00:46:07 +0200 Subject: [PATCH] client: add test with multiple ignores in the config Illustrates https://camlistore.org/r/2296 Fixes http://camlistore.org/issue/390 Change-Id: I8d98a938458239502617352f8eaf1a12f96e50d0 --- pkg/client/ignored_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pkg/client/ignored_test.go b/pkg/client/ignored_test.go index 3f0c8741f..8b412e38e 100644 --- a/pkg/client/ignored_test.go +++ b/pkg/client/ignored_test.go @@ -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 }()