Update expected Cucumber `compose ps` output to match changes

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
This commit is contained in:
Laura Brehm 2022-12-27 02:20:09 +00:00
parent fd353ffa94
commit dde7eea212
No known key found for this signature in database
GPG Key ID: 526E3FC49260D47A
3 changed files with 12 additions and 8 deletions

View File

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

View File

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

View File

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