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

Commit 27d640d

Browse files
committed
e2e test and alignment with docker-compose output
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
1 parent f3d093c commit 27d640d

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

cli/formatter/logs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (l *logConsumer) Log(service, container, message string) {
5353

5454
func (l *logConsumer) Status(service, container, msg string) {
5555
cf := l.getColorFunc(service)
56-
buf := bytes.NewBufferString(fmt.Sprintf("%s %s \n", cf(container), cf(msg)))
56+
buf := bytes.NewBufferString(cf(fmt.Sprintf("%s %s\n", container, msg)))
5757
l.writer.Write(buf.Bytes()) // nolint:errcheck
5858
}
5959

local/compose/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (s *composeService) Start(ctx context.Context, project *types.Project, opti
6262
select {
6363
case status := <-statusC:
6464
service := c.Labels[serviceLabel]
65-
options.Attach.Status(service, getContainerNameWithoutProject(c), fmt.Sprintf("exited with code %d", status.StatusCode))
65+
options.Attach.Status(service, getCanonicalContainerName(c), fmt.Sprintf("exited with code %d", status.StatusCode))
6666
if options.Listener != nil {
6767
options.Listener <- compose.Event{
6868
Service: service,
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
Copyright 2020 Docker Compose CLI authors
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package e2e
18+
19+
import (
20+
"testing"
21+
22+
"gotest.tools/v3/icmd"
23+
24+
. "github.com/docker/compose-cli/utils/e2e"
25+
)
26+
27+
func TestCascadeStop(t *testing.T) {
28+
c := NewParallelE2eCLI(t, binDir)
29+
30+
const projectName = "compose-e2e-logs"
31+
32+
res := c.RunDockerCmd("compose", "-f", "./fixtures/cascade-stop-test/compose.yaml", "--project-name", projectName, "up", "--abort-on-container-exit")
33+
res.Assert(t, icmd.Expected{Out: `PING localhost (127.0.0.1)`})
34+
res.Assert(t, icmd.Expected{Out: `ping_1 exited with code 0`})
35+
res.Assert(t, icmd.Expected{Out: `Aborting on container exit...`})
36+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
services:
2+
ping:
3+
image: busybox:1.27.2
4+
command: ping localhost -c 1

0 commit comments

Comments
 (0)