Skip to content

Commit ecb83b4

Browse files
Add integration tests for stack reason display scenarios
- update-stack: test empty reason for non-active state, test reason with --reason flag - stack: test no reason for active state, test empty reason for non-active state, test reason for non-active state with reason Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 48e7825 commit ecb83b4

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

integration/v7/isolated/stack_command_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ var _ = Describe("stack command", func() {
124124
Eventually(session).Should(Say(`name:\s+%s`, stackName))
125125
Eventually(session).Should(Say(`description:\s+%s`, stackDescription))
126126
Eventually(session).Should(Say(`state:\s+ACTIVE`))
127+
Consistently(session).ShouldNot(Say(`reason:`))
128+
Eventually(session).Should(Exit(0))
129+
})
130+
131+
It("does not show reason for an active stack", func() {
132+
session := helpers.CF("stack", stackName)
133+
134+
Eventually(session).Should(Say(`state:\s+ACTIVE`))
135+
Consistently(session).ShouldNot(Say(`reason:`))
127136
Eventually(session).Should(Exit(0))
128137
})
129138

@@ -137,6 +146,42 @@ var _ = Describe("stack command", func() {
137146
Eventually(session).Should(Say(`^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}`))
138147
Eventually(session).Should(Exit(0))
139148
})
149+
150+
When("the stack is in a non-active state without a reason", func() {
151+
BeforeEach(func() {
152+
session := helpers.CF("update-stack", stackName, "--state", "deprecated")
153+
Eventually(session).Should(Exit(0))
154+
})
155+
156+
It("shows an empty reason field", func() {
157+
session := helpers.CF("stack", stackName)
158+
159+
Eventually(session).Should(Say(`Getting info for stack %s as %s\.\.\.`, stackName, username))
160+
Eventually(session).Should(Say(`name:\s+%s`, stackName))
161+
Eventually(session).Should(Say(`description:\s+%s`, stackDescription))
162+
Eventually(session).Should(Say(`state:\s+DEPRECATED`))
163+
Eventually(session).Should(Say(`reason:\s*$`))
164+
Eventually(session).Should(Exit(0))
165+
})
166+
})
167+
168+
When("the stack is in a non-active state with a reason", func() {
169+
BeforeEach(func() {
170+
session := helpers.CF("update-stack", stackName, "--state", "disabled", "--reason", "This stack is no longer supported.")
171+
Eventually(session).Should(Exit(0))
172+
})
173+
174+
It("shows the reason in the output", func() {
175+
session := helpers.CF("stack", stackName)
176+
177+
Eventually(session).Should(Say(`Getting info for stack %s as %s\.\.\.`, stackName, username))
178+
Eventually(session).Should(Say(`name:\s+%s`, stackName))
179+
Eventually(session).Should(Say(`description:\s+%s`, stackDescription))
180+
Eventually(session).Should(Say(`state:\s+DISABLED`))
181+
Eventually(session).Should(Say(`reason:\s+This stack is no longer supported\.`))
182+
Eventually(session).Should(Exit(0))
183+
})
184+
})
140185
})
141186
})
142187
})

integration/v7/isolated/update_stack_command_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,32 @@ var _ = Describe("update-stack command", func() {
207207
})
208208
})
209209

210+
When("updating to a non-active state without a reason", func() {
211+
It("shows an empty reason field in the output", func() {
212+
session := helpers.CF("update-stack", stackName, "--state", "deprecated")
213+
214+
Eventually(session).Should(Say(`Updating stack %s as %s\.\.\.`, stackName, username))
215+
Eventually(session).Should(Say("OK"))
216+
Eventually(session).Should(Say(`name:\s+%s`, stackName))
217+
Eventually(session).Should(Say(`state:\s+DEPRECATED`))
218+
Eventually(session).Should(Say(`reason:\s*$`))
219+
Eventually(session).Should(Exit(0))
220+
})
221+
})
222+
223+
When("updating with a reason", func() {
224+
It("shows the reason in the update-stack output", func() {
225+
session := helpers.CF("update-stack", stackName, "--state", "disabled", "--reason", "This stack is no longer supported.")
226+
227+
Eventually(session).Should(Say(`Updating stack %s as %s\.\.\.`, stackName, username))
228+
Eventually(session).Should(Say("OK"))
229+
Eventually(session).Should(Say(`name:\s+%s`, stackName))
230+
Eventually(session).Should(Say(`state:\s+DISABLED`))
231+
Eventually(session).Should(Say(`reason:\s+This stack is no longer supported\.`))
232+
Eventually(session).Should(Exit(0))
233+
})
234+
})
235+
210236
When("state value is provided in different cases", func() {
211237
It("accepts lowercase state value", func() {
212238
session := helpers.CF("update-stack", stackName, "--state", "deprecated")

0 commit comments

Comments
 (0)