Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 8b90814

Browse files
committed
e2e test
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent d9fe745 commit 8b90814

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

api/compose/api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ type CreateOptions struct {
6565

6666
// StartOptions group options of the Start API
6767
type StartOptions struct {
68-
// Attach will attach to service containers and pipe stdout/stderr to channel
68+
// Attach will attach to service containers and send container logs and events
6969
Attach ContainerEventListener
7070
}
7171

cli/cmd/compose/up.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ func runCreateStart(ctx context.Context, opts upOptions, services []string) erro
133133
return err
134134
}
135135

136+
if opts.exitCodeFrom != "" {
137+
_, err := project.GetService(opts.exitCodeFrom)
138+
if err != nil {
139+
return err
140+
}
141+
}
142+
136143
_, err = progress.Run(ctx, func(ctx context.Context) (string, error) {
137144
err := c.ComposeService().Create(ctx, project, compose.CreateOptions{
138145
RemoveOrphans: opts.removeOrphans,

local/e2e/compose/cascade_stop_test.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,19 @@ func TestCascadeStop(t *testing.T) {
3030
const projectName = "compose-e2e-logs"
3131

3232
t.Run("abort-on-container-exit", func(t *testing.T) {
33-
res := c.RunDockerCmd("compose", "-f", "./fixtures/cascade-stop-test/compose.yaml", "--project-name", projectName, "up", "--abort-on-container-exit")
34-
res.Assert(t, icmd.Expected{Out: `/does_not_exist: No such file or directory`})
35-
res.Assert(t, icmd.Expected{Out: `should_fail_1 exited with code 1`})
36-
res.Assert(t, icmd.Expected{Out: `Aborting on container exit...`})
37-
res.Assert(t, icmd.Expected{Out: `ERROR 1`})
38-
res.Assert(t, icmd.Expected{ExitCode: 1})
33+
res := c.RunDockerOrExitError("compose", "-f", "./fixtures/cascade-stop-test/compose.yaml", "--project-name", projectName, "up", "--abort-on-container-exit")
34+
res.Assert(t, icmd.Expected{ExitCode: 1, Out: `should_fail_1 exited with code 1`})
35+
res.Assert(t, icmd.Expected{ExitCode: 1, Out: `Aborting on container exit...`})
3936
})
4037

4138
t.Run("exit-code-from", func(t *testing.T) {
42-
res := c.RunDockerCmd("compose", "-f", "./fixtures/cascade-stop-test/compose.yaml", "--project-name", projectName, "up", "--exit-code-from=sleep")
43-
res.Assert(t, icmd.Expected{Out: `/does_not_exist: No such file or directory`})
44-
res.Assert(t, icmd.Expected{Out: `should_fail_1 exited with code 1`})
45-
res.Assert(t, icmd.Expected{Out: `Aborting on container exit...`})
46-
res.Assert(t, icmd.Expected{Out: `ERROR 143`})
47-
res.Assert(t, icmd.Expected{ExitCode: 143})
39+
res := c.RunDockerOrExitError("compose", "-f", "./fixtures/cascade-stop-test/compose.yaml", "--project-name", projectName, "up", "--exit-code-from=sleep")
40+
res.Assert(t, icmd.Expected{ExitCode: 137, Out: `should_fail_1 exited with code 1`})
41+
res.Assert(t, icmd.Expected{ExitCode: 137, Out: `Aborting on container exit...`})
42+
})
43+
44+
t.Run("exit-code-from unknown", func(t *testing.T) {
45+
res := c.RunDockerOrExitError("compose", "-f", "./fixtures/cascade-stop-test/compose.yaml", "--project-name", projectName, "up", "--exit-code-from=unknown")
46+
res.Assert(t, icmd.Expected{ExitCode: 1, Err: `no such service: unknown`})
4847
})
4948
}

local/e2e/compose/fixtures/cascade-stop-test/compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ services:
44
command: ls /does_not_exist
55
sleep: # will be killed
66
image: busybox:1.27.2
7-
command: sleep 10
7+
command: ping localhost

0 commit comments

Comments
 (0)