mirror of
https://github.com/docker/compose.git
synced 2025-07-29 16:44:20 +02:00
e2e test for watch.include
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
0ef7bbcddc
commit
19571c2c81
12
pkg/e2e/fixtures/watch/include.yaml
Normal file
12
pkg/e2e/fixtures/watch/include.yaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
services:
|
||||||
|
a:
|
||||||
|
build:
|
||||||
|
dockerfile_inline: |
|
||||||
|
FROM nginx
|
||||||
|
RUN mkdir /data/
|
||||||
|
develop:
|
||||||
|
watch:
|
||||||
|
- path: .
|
||||||
|
include: A.*
|
||||||
|
target: /data/
|
||||||
|
action: sync
|
@ -368,3 +368,40 @@ func TestWatchMultiServices(t *testing.T) {
|
|||||||
|
|
||||||
c.RunDockerComposeCmdNoCheck(t, "-p", projectName, "kill", "-s", "9")
|
c.RunDockerComposeCmdNoCheck(t, "-p", projectName, "kill", "-s", "9")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWatchIncludes(t *testing.T) {
|
||||||
|
c := NewCLI(t)
|
||||||
|
const projectName = "test_watch_includes"
|
||||||
|
|
||||||
|
defer c.cleanupWithDown(t, projectName)
|
||||||
|
|
||||||
|
tmpdir := t.TempDir()
|
||||||
|
composeFilePath := filepath.Join(tmpdir, "compose.yaml")
|
||||||
|
CopyFile(t, filepath.Join("fixtures", "watch", "include.yaml"), composeFilePath)
|
||||||
|
|
||||||
|
cmd := c.NewDockerComposeCmd(t, "-p", projectName, "-f", composeFilePath, "up", "--watch")
|
||||||
|
buffer := bytes.NewBuffer(nil)
|
||||||
|
cmd.Stdout = buffer
|
||||||
|
watch := icmd.StartCmd(cmd)
|
||||||
|
|
||||||
|
poll.WaitOn(t, func(l poll.LogT) poll.Result {
|
||||||
|
if strings.Contains(watch.Stdout(), "Attaching to ") {
|
||||||
|
return poll.Success()
|
||||||
|
}
|
||||||
|
return poll.Continue("%v", watch.Stdout())
|
||||||
|
})
|
||||||
|
|
||||||
|
require.NoError(t, os.WriteFile(filepath.Join(tmpdir, "B.test"), []byte("test"), 0o600))
|
||||||
|
require.NoError(t, os.WriteFile(filepath.Join(tmpdir, "A.test"), []byte("test"), 0o600))
|
||||||
|
|
||||||
|
poll.WaitOn(t, func(l poll.LogT) poll.Result {
|
||||||
|
cat := c.RunDockerComposeCmdNoCheck(t, "-p", projectName, "exec", "a", "ls", "/data/")
|
||||||
|
if strings.Contains(cat.Stdout(), "A.test") {
|
||||||
|
assert.Check(t, !strings.Contains(cat.Stdout(), "B.test"))
|
||||||
|
return poll.Success()
|
||||||
|
}
|
||||||
|
return poll.Continue("%v", cat.Combined())
|
||||||
|
})
|
||||||
|
|
||||||
|
c.RunDockerComposeCmdNoCheck(t, "-p", projectName, "kill", "-s", "9")
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user