@@ -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})
0 commit comments