Skip to content

Commit 82b8981

Browse files
chore: Fix flaky deploy tests (#565)
1 parent af34422 commit 82b8981

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

pkg/cmd/release/deploy/deploy_test.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ import (
99
"testing"
1010
"time"
1111

12-
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/configuration"
13-
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments/v2/ephemeralenvironments"
14-
1512
"github.com/AlecAivazis/survey/v2"
1613
surveyCore "github.com/AlecAivazis/survey/v2/core"
1714
"github.com/MakeNowJust/heredoc/v2"
@@ -25,9 +22,11 @@ import (
2522
"github.com/OctopusDeploy/cli/test/testutil"
2623
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/channels"
2724
octopusApiClient "github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
25+
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/configuration"
2826
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core"
2927
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/deployments"
3028
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments"
29+
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/environments/v2/ephemeralenvironments"
3130
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/projects"
3231
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/releases"
3332
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/resources"
@@ -570,12 +569,11 @@ func TestDeployCreate_AskQuestions(t *testing.T) {
570569
validationErr = q.AnswerWith("John")
571570
assert.Nil(t, validationErr)
572571

573-
assert.Equal(t, heredoc.Doc(`
572+
assert.Contains(t, stdout.String(), heredoc.Doc(`
574573
Project Fire Project
575574
Release 2.0
576575
Environments dev
577576
`), stdout.String())
578-
stdout.Reset()
579577

580578
q = qa.ExpectQuestion(t, &survey.Select{
581579
Message: "Change additional options?",
@@ -584,6 +582,8 @@ func TestDeployCreate_AskQuestions(t *testing.T) {
584582
assert.Regexp(t, "Additional Options", stdout.String()) // actual options tested in PrintAdvancedSummary
585583
_ = q.AnswerWith("Proceed to deploy")
586584

585+
stdout.Reset()
586+
587587
err := <-errReceiver
588588
assert.Nil(t, err)
589589

@@ -758,11 +758,10 @@ func TestDeployCreate_AskQuestions(t *testing.T) {
758758
emptyDeploymentPreviews := fixtures.EmptyDeploymentPreviews()
759759
api.ExpectRequest(t, "POST", "/api/Spaces-1/releases/"+release19.ID+"/deployments/previews").RespondWith(&emptyDeploymentPreviews)
760760

761-
assert.Equal(t, heredoc.Doc(`
761+
assert.Contains(t, heredoc.Doc(`
762762
Project Fire Project
763763
Release 1.9
764764
`), stdout.String())
765-
stdout.Reset()
766765

767766
q = qa.ExpectQuestion(t, &survey.Select{
768767
Message: "Change additional options?",
@@ -771,6 +770,8 @@ func TestDeployCreate_AskQuestions(t *testing.T) {
771770
assert.Regexp(t, "Additional Options", stdout.String()) // actual options tested in PrintAdvancedSummary
772771
_ = q.AnswerWith("Proceed to deploy")
773772

773+
stdout.Reset()
774+
774775
err := <-errReceiver
775776
assert.Nil(t, err)
776777

@@ -868,11 +869,10 @@ func TestDeployCreate_AskQuestions(t *testing.T) {
868869
emptyDeploymentPreviews := fixtures.EmptyDeploymentPreviews()
869870
api.ExpectRequest(t, "POST", "/api/Spaces-1/releases/"+release19.ID+"/deployments/previews").RespondWith(&emptyDeploymentPreviews)
870871

871-
assert.Equal(t, heredoc.Doc(`
872+
assert.Contains(t, stdout.String(), heredoc.Doc(`
872873
Project Fire Project
873874
Release 1.9
874-
`), stdout.String())
875-
stdout.Reset()
875+
`))
876876

877877
q = qa.ExpectQuestion(t, &survey.Select{
878878
Message: "Change additional options?",
@@ -881,6 +881,7 @@ func TestDeployCreate_AskQuestions(t *testing.T) {
881881
assert.Regexp(t, "Additional Options", stdout.String()) // actual options tested in PrintAdvancedSummary
882882
_ = q.AnswerWith("Proceed to deploy")
883883

884+
stdout.Reset()
884885
err := <-errReceiver
885886
assert.Nil(t, err)
886887

@@ -1061,16 +1062,15 @@ func TestDeployCreate_AskQuestions(t *testing.T) {
10611062
emptyDeploymentPreviews := fixtures.EmptyDeploymentPreviews()
10621063
api.ExpectRequest(t, "POST", "/api/Spaces-1/releases/"+release19.ID+"/deployments/previews").RespondWith(&emptyDeploymentPreviews)
10631064

1064-
assert.Equal(t, heredoc.Doc(`
1065+
assert.Contains(t, stdout.String(), heredoc.Doc(`
10651066
Project Fire Project
10661067
Release 1.9
10671068
Warning: The following packages are missing from the built-in feed for this release:
10681069
- apples (Version: 1.0.0)
10691070
- bananas (Version: 2.0.0)
10701071
10711072
This might cause the deployment to fail.
1072-
`), stdout.String())
1073-
stdout.Reset()
1073+
`))
10741074

10751075
q := qa.ExpectQuestion(t, &survey.Select{
10761076
Message: "Change additional options?",
@@ -1079,6 +1079,8 @@ func TestDeployCreate_AskQuestions(t *testing.T) {
10791079
assert.Regexp(t, "Additional Options", stdout.String()) // actual options tested in PrintAdvancedSummary
10801080
_ = q.AnswerWith("Proceed to deploy")
10811081

1082+
stdout.Reset()
1083+
10821084
err := <-errReceiver
10831085
assert.Nil(t, err)
10841086

0 commit comments

Comments
 (0)