From 813238a7c76a6b1ca4e027b4dcef1f16bd7bf487 Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Wed, 28 Oct 2026 09:14:42 +0100 Subject: [PATCH] test(e2e): migrate TestEventsUnknownService to a scenario Express the intent (events refuses a service outside the project) with the Scenario DSL; the project now lives in testdata/TestEventsUnknownService. The shared fixtures/simple-composefile is still used by another test. Signed-off-by: Nicolas De Loof --- pkg/e2e/events_test.go | 13 +++++-------- .../testdata/TestEventsUnknownService/compose.yaml | 7 +++++++ 2 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 pkg/e2e/testdata/TestEventsUnknownService/compose.yaml diff --git a/pkg/e2e/events_test.go b/pkg/e2e/events_test.go index ef20d7264..38b74de9c 100644 --- a/pkg/e2e/events_test.go +++ b/pkg/e2e/events_test.go @@ -21,15 +21,12 @@ package e2e import ( "testing" "time" - - "gotest.tools/v3/icmd" ) func TestEventsUnknownService(t *testing.T) { - c := NewParallelCLI(t) - - cmd := c.NewDockerComposeCmd(t, "-f", "./fixtures/simple-composefile/compose.yaml", "events", "not-a-service") - cmd.Timeout = 10 * time.Second - res := icmd.RunCmd(cmd) - res.Assert(t, icmd.Expected{ExitCode: 1, Err: "no such service: not-a-service"}) + NewScenario(t, "events must refuse a service that is not in the project"). + Step("events on an unknown service fails and names it", + ComposeCmd("events", "not-a-service").MayFail().Within(10*time.Second), + ExitCode(1), + StderrContains("no such service: not-a-service")) } diff --git a/pkg/e2e/testdata/TestEventsUnknownService/compose.yaml b/pkg/e2e/testdata/TestEventsUnknownService/compose.yaml new file mode 100644 index 000000000..8b0b49ea1 --- /dev/null +++ b/pkg/e2e/testdata/TestEventsUnknownService/compose.yaml @@ -0,0 +1,7 @@ +services: + simple: + image: alpine + command: top + another: + image: alpine + command: top