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 <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2026-10-28 09:14:42 +01:00 • committed by Guillaume Lours
parent 783cd10211
commit 813238a7c7
2 changed files with 12 additions and 8 deletions

View file

@ -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"))
}

View file

@ -0,0 +1,7 @@
services:
simple:
image: alpine
command: top
another:
image: alpine
command: top