Skip to content

Commit b22dde9

Browse files
nicksndeloof
authored andcommitted
dockerignore: improve MatchesEntireDir (docker#1865)
1 parent a31350e commit b22dde9

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

pkg/watch/notify_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,32 @@ func TestIgnoreCreatedDir(t *testing.T) {
509509
assert.Equal(t, expectedWatches, int(numberOfWatches.Value()))
510510
}
511511

512+
func TestIgnoreCreatedDirWithExclusions(t *testing.T) {
513+
f := newNotifyFixture(t)
514+
defer f.tearDown()
515+
516+
root := f.paths[0]
517+
ignore, _ := dockerignore.NewDockerPatternMatcher(root,
518+
[]string{
519+
"a/b",
520+
"c",
521+
"!c/d",
522+
})
523+
f.setIgnore(ignore)
524+
525+
a := f.JoinPath(root, "a")
526+
b := f.JoinPath(a, "b")
527+
file := f.JoinPath(b, "bigFile")
528+
f.WriteFile(file, "hello")
529+
f.assertEvents(a)
530+
531+
expectedWatches := 2
532+
if runtime.GOOS == "darwin" {
533+
expectedWatches = 1
534+
}
535+
assert.Equal(t, expectedWatches, int(numberOfWatches.Value()))
536+
}
537+
512538
func TestIgnoreInitialDir(t *testing.T) {
513539
f := newNotifyFixture(t)
514540
defer f.tearDown()

0 commit comments

Comments
 (0)