From b22dde9f189c87f155100f060abfdc168576bd97 Mon Sep 17 00:00:00 2001 From: Nick Santos Date: Tue, 16 Jul 2019 16:53:07 -0400 Subject: [PATCH] dockerignore: improve MatchesEntireDir (#1865) --- pkg/watch/notify_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pkg/watch/notify_test.go b/pkg/watch/notify_test.go index 7754b14f6..a3a2bcc7f 100644 --- a/pkg/watch/notify_test.go +++ b/pkg/watch/notify_test.go @@ -509,6 +509,32 @@ func TestIgnoreCreatedDir(t *testing.T) { assert.Equal(t, expectedWatches, int(numberOfWatches.Value())) } +func TestIgnoreCreatedDirWithExclusions(t *testing.T) { + f := newNotifyFixture(t) + defer f.tearDown() + + root := f.paths[0] + ignore, _ := dockerignore.NewDockerPatternMatcher(root, + []string{ + "a/b", + "c", + "!c/d", + }) + f.setIgnore(ignore) + + a := f.JoinPath(root, "a") + b := f.JoinPath(a, "b") + file := f.JoinPath(b, "bigFile") + f.WriteFile(file, "hello") + f.assertEvents(a) + + expectedWatches := 2 + if runtime.GOOS == "darwin" { + expectedWatches = 1 + } + assert.Equal(t, expectedWatches, int(numberOfWatches.Value())) +} + func TestIgnoreInitialDir(t *testing.T) { f := newNotifyFixture(t) defer f.tearDown()