From dde7eea212c7be40d2fb1e9e5cb837899e2d7dbf Mon Sep 17 00:00:00 2001 From: Laura Brehm Date: Tue, 27 Dec 2022 02:20:09 +0000 Subject: [PATCH] Update expected Cucumber `compose ps` output to match changes Signed-off-by: Laura Brehm --- e2e/cucumber-features/simple.feature | 2 +- e2e/cucumber-features/start.feature | 4 ++-- e2e/cucumber_test.go | 14 +++++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/e2e/cucumber-features/simple.feature b/e2e/cucumber-features/simple.feature index ac560b1d1..6a208804e 100644 --- a/e2e/cucumber-features/simple.feature +++ b/e2e/cucumber-features/simple.feature @@ -12,4 +12,4 @@ Background: Scenario: compose up When I run "compose up -d" Then the output contains "simple-1 Started" - And service "simple" is "running" + And service "simple" is "Up" diff --git a/e2e/cucumber-features/start.feature b/e2e/cucumber-features/start.feature index ebf994a3d..a577a98cd 100644 --- a/e2e/cucumber-features/start.feature +++ b/e2e/cucumber-features/start.feature @@ -17,5 +17,5 @@ Scenario: Start single service Then the output contains "simple-1 Created" And the output contains "another-1 Created" Then I run "compose start another" - And service "another" is "running" - And service "simple" is "created" + And service "another" is "Up" + And service "simple" is "Created" diff --git a/e2e/cucumber_test.go b/e2e/cucumber_test.go index 8a1571d1c..f9c44e7bd 100644 --- a/e2e/cucumber_test.go +++ b/e2e/cucumber_test.go @@ -57,12 +57,14 @@ func TestCucumber(t *testing.T) { func setup(s *godog.ScenarioContext) { t := s.TestingT() + projectName := strings.Split(t.Name(), "/")[1] cli := e2e.NewCLI(t, e2e.WithEnv( - fmt.Sprintf("COMPOSE_PROJECT_NAME=%s", strings.Split(t.Name(), "/")[1]), + fmt.Sprintf("COMPOSE_PROJECT_NAME=%s", projectName), )) th := testHelper{ - T: t, - CLI: cli, + T: t, + CLI: cli, + ProjectName: projectName, } s.Before(func(ctx context.Context, sc *godog.Scenario) (context.Context, error) { @@ -84,6 +86,7 @@ func setup(s *godog.ScenarioContext) { type testHelper struct { T *testing.T + ProjectName string ComposeFile string CommandOutput string CommandExitCode int @@ -91,11 +94,12 @@ type testHelper struct { } func (th *testHelper) serviceIsStatus(service, status string) error { + serviceContainerName := fmt.Sprintf("%s-%s-1", strings.ToLower(th.ProjectName), service) + statusRegex := fmt.Sprintf("%s.*%s", serviceContainerName, status) res := th.CLI.RunDockerComposeCmd(th.T, "ps", "-a") - statusRegex := fmt.Sprintf("%s\\s+%s", service, status) r, _ := regexp.Compile(statusRegex) if !r.MatchString(res.Combined()) { - return fmt.Errorf("Missing/incorrect ps output:\n%s", res.Combined()) + return fmt.Errorf("Missing/incorrect ps output:\n%s\nregex:\n%s", res.Combined(), statusRegex) } return nil }