diff --git a/cli/cmd/compose/ps.go b/cli/cmd/compose/ps.go index d73bb18af..617367ab0 100644 --- a/cli/cmd/compose/ps.go +++ b/cli/cmd/compose/ps.go @@ -93,8 +93,12 @@ func runPs(ctx context.Context, opts psOptions) error { ports = append(ports, fmt.Sprintf("%s->%d/%s", p.URL, p.TargetPort, p.Protocol)) } } - _, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\t%s\n", container.Name, container.Service, container.State, container.Health, strings.Join(ports, ", ")) + status := container.State + if container.Health != "" { + status = fmt.Sprintf("%s (%s)", container.State, container.Health) + } + _, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", container.Name, container.Service, status, strings.Join(ports, ", ")) } }, - "NAME", "SERVICE", "STATE", "HEALTH", "PORTS") + "NAME", "SERVICE", "STATUS", "PORTS") } diff --git a/local/e2e/compose/compose_test.go b/local/e2e/compose/compose_test.go index 9e095c9b7..2b0120a23 100644 --- a/local/e2e/compose/compose_test.go +++ b/local/e2e/compose/compose_test.go @@ -89,10 +89,15 @@ func TestLocalComposeUp(t *testing.T) { }) - t.Run("check healthcheck display", func(t *testing.T) { + t.Run("check healthcheck output", func(t *testing.T) { c.WaitForCmdResult(c.NewDockerCmd("compose", "-p", projectName, "ps", "--format", "json"), StdoutContains(`"Name":"compose-e2e-demo_web_1","Project":"compose-e2e-demo","Service":"web","State":"running","Health":"healthy"`), 5*time.Second, 1*time.Second) + + res := c.RunDockerCmd("compose", "-p", projectName, "ps") + res.Assert(t, icmd.Expected{Out: `NAME SERVICE STATUS PORTS`}) + res.Assert(t, icmd.Expected{Out: `compose-e2e-demo_web_1 web running (healthy) 0.0.0.0:90->80/tcp`}) + res.Assert(t, icmd.Expected{Out: `compose-e2e-demo_db_1 db running 5432/tcp`}) }) t.Run("down", func(t *testing.T) { diff --git a/local/e2e/compose/fixtures/sentences/compose.yaml b/local/e2e/compose/fixtures/sentences/compose.yaml index 74d5ce38b..7916d1f4b 100644 --- a/local/e2e/compose/fixtures/sentences/compose.yaml +++ b/local/e2e/compose/fixtures/sentences/compose.yaml @@ -13,4 +13,4 @@ services: - "my-label=test" healthcheck: test: ["CMD", "curl", "-f", "http://localhost:80/"] - interval: 5s + interval: 2s