瀏覽代碼

dockerignore: improve MatchesEntireDir (#1865)

Nick Santos 6 年之前
父節點
當前提交
b22dde9f18
共有 1 個文件被更改,包括 26 次插入0 次删除
  1. 26 0
      pkg/watch/notify_test.go

+ 26 - 0
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()