Skip to content

Commit

Permalink
Update expected Cucumber compose ps output to match changes
Browse files Browse the repository at this point in the history
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
  • Loading branch information
laurazard committed Dec 30, 2022
1 parent fd353ff commit dde7eea
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion e2e/cucumber-features/simple.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions e2e/cucumber-features/start.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"
14 changes: 9 additions & 5 deletions e2e/cucumber_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -84,18 +86,20 @@ func setup(s *godog.ScenarioContext) {

type testHelper struct {
T *testing.T
ProjectName string
ComposeFile string
CommandOutput string
CommandExitCode int
CLI *e2e.CLI
}

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
}
Expand Down

0 comments on commit dde7eea

Please sign in to comment.