Skip to content

Commit

Permalink
Refactor app summary displayer tests to use Say instead of MatchRegexp
Browse files Browse the repository at this point in the history
Co-authored-by: Greg Weresch <greg.weresch@broadcom.com>
  • Loading branch information
weresch authored and pivotalgeorge committed Aug 14, 2024
1 parent a3332eb commit a2bb971
Showing 1 changed file with 15 additions and 24 deletions.
39 changes: 15 additions & 24 deletions command/v7/shared/app_summary_displayer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,7 @@ var _ = Describe("app summary displayer", func() {
})

It("displays the message", func() {
var actualOut = fmt.Sprintf("%s", testUI.Out)
Expect(actualOut).To(MatchRegexp(`Rolling deployment currently DEPLOYING \(since %s\)`, dateTimeRegexPattern))
Expect(testUI.Out).To(Say(`Rolling deployment currently DEPLOYING \(since %s\)`, dateTimeRegexPattern))
})

It("displays max-in-flight value", func() {
Expand All @@ -743,17 +742,15 @@ var _ = Describe("app summary displayer", func() {
})

It("displays the message", func() {
var actualOut = fmt.Sprintf("%s", testUI.Out)
Expect(actualOut).To(MatchRegexp(`Rolling deployment currently DEPLOYING \(since %s\)`, dateTimeRegexPattern))
Expect(testUI.Out).To(Say(`Rolling deployment currently DEPLOYING \(since %s\)`, dateTimeRegexPattern))
})

It("does not display max-in-flight", func() {
Expect(testUI.Out).NotTo(Say(`max-in-flight`))
})
})

// 'unset' is important for the newer-CLI-than-CAPI scenario
When("last status change has a timestamp and max-in-flight is unset", func() {
When("an older version of CAPI does not return max-in-flight", func() {
BeforeEach(func() {
summary = v7action.DetailedApplicationSummary{
Deployment: resources.Deployment{
Expand All @@ -766,8 +763,7 @@ var _ = Describe("app summary displayer", func() {
})

It("displays the message", func() {
var actualOut = fmt.Sprintf("%s", testUI.Out)
Expect(actualOut).To(MatchRegexp(`Rolling deployment currently DEPLOYING \(since %s\)`, dateTimeRegexPattern))
Expect(testUI.Out).To(Say(`Rolling deployment currently DEPLOYING \(since %s\)`, dateTimeRegexPattern))
})

It("does not display max-in-flight", func() {
Expand Down Expand Up @@ -843,8 +839,7 @@ var _ = Describe("app summary displayer", func() {
})

It("displays the message", func() {
var actualOut = fmt.Sprintf("%s", testUI.Out)
Expect(actualOut).To(MatchRegexp(`Rolling deployment currently CANCELING \(since %s\)`, dateTimeRegexPattern))
Expect(testUI.Out).To(Say(`Rolling deployment currently CANCELING \(since %s\)`, dateTimeRegexPattern))
})

It("displays max-in-flight value", func() {
Expand All @@ -868,8 +863,7 @@ var _ = Describe("app summary displayer", func() {
})

It("displays the message", func() {
var actualOut = fmt.Sprintf("%s", testUI.Out)
Expect(actualOut).To(MatchRegexp(`Rolling deployment currently CANCELING \(since %s\)`, dateTimeRegexPattern))
Expect(testUI.Out).To(Say(`Rolling deployment currently CANCELING \(since %s\)`, dateTimeRegexPattern))
})

It("does not display max-in-flight", func() {
Expand All @@ -878,6 +872,7 @@ var _ = Describe("app summary displayer", func() {
})
})
})

When("the deployment strategy is canary", func() {
When("the deployment is in progress", func() {
When("max-in-flight value is non-default", func() {
Expand All @@ -896,8 +891,7 @@ var _ = Describe("app summary displayer", func() {
})

It("displays the message", func() {
var actualOut = fmt.Sprintf("%s", testUI.Out)
Expect(actualOut).To(MatchRegexp(`Canary deployment currently DEPLOYING \(since %s\)`, dateTimeRegexPattern))
Expect(testUI.Out).To(Say(`Canary deployment currently DEPLOYING \(since %s\)`, dateTimeRegexPattern))
Expect(testUI.Out).NotTo(Say(`promote the canary deployment`))
})

Expand All @@ -922,8 +916,7 @@ var _ = Describe("app summary displayer", func() {
})

It("displays the message", func() {
var actualOut = fmt.Sprintf("%s", testUI.Out)
Expect(actualOut).To(MatchRegexp(`Canary deployment currently DEPLOYING \(since %s\)`, dateTimeRegexPattern))
Expect(testUI.Out).To(Say(`Canary deployment currently DEPLOYING \(since %s\)`, dateTimeRegexPattern))
Expect(testUI.Out).NotTo(Say(`promote the canary deployment`))
})

Expand Down Expand Up @@ -955,15 +948,15 @@ var _ = Describe("app summary displayer", func() {
})

It("displays the message", func() {
var actualOut = fmt.Sprintf("%s", testUI.Out)
Expect(actualOut).To(MatchRegexp(`Canary deployment currently PAUSED \(since %s\)`, dateTimeRegexPattern))
Expect(testUI.Out).To(Say(`Canary deployment currently PAUSED \(since %s\)`, dateTimeRegexPattern))
Expect(testUI.Out).To(Say("Please run `cf continue-deployment foobar` to promote the canary deployment, or `cf cancel-deployment foobar` to rollback to the previous version."))
})

It("displays max-in-flight value", func() {
Expect(testUI.Out).To(Say(`max-in-flight: 2`))
})
})

When("max-in-flight value is default", func() {
BeforeEach(func() {
summary = v7action.DetailedApplicationSummary{
Expand All @@ -985,8 +978,7 @@ var _ = Describe("app summary displayer", func() {
})

It("displays the message", func() {
var actualOut = fmt.Sprintf("%s", testUI.Out)
Expect(actualOut).To(MatchRegexp(`Canary deployment currently PAUSED \(since %s\)`, dateTimeRegexPattern))
Expect(testUI.Out).To(Say(`Canary deployment currently PAUSED \(since %s\)`, dateTimeRegexPattern))
Expect(testUI.Out).To(Say("Please run `cf continue-deployment foobar` to promote the canary deployment, or `cf cancel-deployment foobar` to rollback to the previous version."))
})

Expand All @@ -1013,15 +1005,15 @@ var _ = Describe("app summary displayer", func() {
})

It("displays the message", func() {
var actualOut = fmt.Sprintf("%s", testUI.Out)
Expect(actualOut).To(MatchRegexp(`Canary deployment currently CANCELING \(since %s\)`, dateTimeRegexPattern))
Expect(testUI.Out).To(Say(`Canary deployment currently CANCELING \(since %s\)`, dateTimeRegexPattern))
Expect(testUI.Out).NotTo(Say(`promote the canary deployment`))
})

It("displays max-in-flight value", func() {
Expect(testUI.Out).To(Say(`max-in-flight: 2`))
})
})

When("max-in-flight value is default", func() {
BeforeEach(func() {
summary = v7action.DetailedApplicationSummary{
Expand All @@ -1038,8 +1030,7 @@ var _ = Describe("app summary displayer", func() {
})

It("displays the message", func() {
var actualOut = fmt.Sprintf("%s", testUI.Out)
Expect(actualOut).To(MatchRegexp(`Canary deployment currently CANCELING \(since %s\)`, dateTimeRegexPattern))
Expect(testUI.Out).To(Say(`Canary deployment currently CANCELING \(since %s\)`, dateTimeRegexPattern))
Expect(testUI.Out).NotTo(Say(`promote the canary deployment`))
})

Expand Down

0 comments on commit a2bb971

Please sign in to comment.