Skip to content

Commit 19571c2

Browse files
committed
e2e test for watch.include
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 0ef7bbc commit 19571c2

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
services:
2+
a:
3+
build:
4+
dockerfile_inline: |
5+
FROM nginx
6+
RUN mkdir /data/
7+
develop:
8+
watch:
9+
- path: .
10+
include: A.*
11+
target: /data/
12+
action: sync

pkg/e2e/watch_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,3 +368,40 @@ func TestWatchMultiServices(t *testing.T) {
368368

369369
c.RunDockerComposeCmdNoCheck(t, "-p", projectName, "kill", "-s", "9")
370370
}
371+
372+
func TestWatchIncludes(t *testing.T) {
373+
c := NewCLI(t)
374+
const projectName = "test_watch_includes"
375+
376+
defer c.cleanupWithDown(t, projectName)
377+
378+
tmpdir := t.TempDir()
379+
composeFilePath := filepath.Join(tmpdir, "compose.yaml")
380+
CopyFile(t, filepath.Join("fixtures", "watch", "include.yaml"), composeFilePath)
381+
382+
cmd := c.NewDockerComposeCmd(t, "-p", projectName, "-f", composeFilePath, "up", "--watch")
383+
buffer := bytes.NewBuffer(nil)
384+
cmd.Stdout = buffer
385+
watch := icmd.StartCmd(cmd)
386+
387+
poll.WaitOn(t, func(l poll.LogT) poll.Result {
388+
if strings.Contains(watch.Stdout(), "Attaching to ") {
389+
return poll.Success()
390+
}
391+
return poll.Continue("%v", watch.Stdout())
392+
})
393+
394+
require.NoError(t, os.WriteFile(filepath.Join(tmpdir, "B.test"), []byte("test"), 0o600))
395+
require.NoError(t, os.WriteFile(filepath.Join(tmpdir, "A.test"), []byte("test"), 0o600))
396+
397+
poll.WaitOn(t, func(l poll.LogT) poll.Result {
398+
cat := c.RunDockerComposeCmdNoCheck(t, "-p", projectName, "exec", "a", "ls", "/data/")
399+
if strings.Contains(cat.Stdout(), "A.test") {
400+
assert.Check(t, !strings.Contains(cat.Stdout(), "B.test"))
401+
return poll.Success()
402+
}
403+
return poll.Continue("%v", cat.Combined())
404+
})
405+
406+
c.RunDockerComposeCmdNoCheck(t, "-p", projectName, "kill", "-s", "9")
407+
}

0 commit comments

Comments
 (0)