Răsfoiți Sursa

Update expected Cucumber `compose ps` output to match changes

Signed-off-by: Laura Brehm <[email protected]>
Laura Brehm 2 ani în urmă
părinte
comite
dde7eea212

+ 1 - 1
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"

+ 2 - 2
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"

+ 9 - 5
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
 }