@@ -33,7 +33,7 @@ var _ = Describe("stack command", func() {
3333 It ("appears in cf help -a" , func () {
3434 session := helpers .CF ("help" , "-a" )
3535 Eventually (session ).Should (Exit (0 ))
36- Expect (session ).To (HaveCommandInCategoryWithDescription ("stack" , "APPS" , "Show information for a stack (a stack is a pre-built file system, including an operating system, that can run apps)" ))
36+ Expect (session ).To (HaveCommandInCategoryWithDescription ("stack" , "APPS" , "Show information for a stack (a stack is a pre-built file system, including an operating system, that can run apps) and current state " ))
3737 })
3838
3939 It ("Displays command usage to output" , func () {
@@ -100,71 +100,42 @@ var _ = Describe("stack command", func() {
100100 })
101101 })
102102
103- When ("the stack exists" , func () {
103+ When ("the stack exists with valid state " , func () {
104104 var stackGUID string
105105
106- Context ("when the stack has no state" , func () {
107- BeforeEach (func () {
108- jsonBody := fmt .Sprintf (`{"name": "%s", "description": "%s"}` , stackName , stackDescription )
109- session := helpers .CF ("curl" , "-d" , jsonBody , "-X" , "POST" , "/v3/stacks" )
110- Eventually (session ).Should (Exit (0 ))
111-
112- r := regexp .MustCompile (`[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}` )
113- stackGUID = string (r .Find (session .Out .Contents ()))
114- })
115-
116- AfterEach (func () {
117- session := helpers .CF ("curl" , "-X" , "DELETE" , fmt .Sprintf ("/v3/stacks/%s" , stackGUID ))
118- Eventually (session ).Should (Exit (0 ))
119- })
120-
121- It ("Shows the details for the stack without state" , func () {
122- session := helpers .CF ("stack" , stackName )
106+ BeforeEach (func () {
107+ jsonBody := fmt .Sprintf (`{"name": "%s", "description": "%s", "state": "ACTIVE"}` , stackName , stackDescription )
108+ session := helpers .CF ("curl" , "-d" , jsonBody , "-X" , "POST" , "/v3/stacks" )
109+ Eventually (session ).Should (Exit (0 ))
123110
124- Eventually (session ).Should (Say (`Getting info for stack %s as %s\.\.\.` , stackName , username ))
125- Eventually (session ).Should (Say (`name:\s+%s` , stackName ))
126- Eventually (session ).Should (Say (`description:\s+%s` , stackDescription ))
127- Consistently (session ).ShouldNot (Say (`state:` ))
128- Eventually (session ).Should (Exit (0 ))
129- })
111+ r := regexp .MustCompile (`[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}` )
112+ stackGUID = string (r .Find (session .Out .Contents ()))
130113 })
131114
132- Context ("when the stack has a valid state" , func () {
133- BeforeEach (func () {
134- jsonBody := fmt .Sprintf (`{"name": "%s", "description": "%s", "state": "ACTIVE"}` , stackName , stackDescription )
135- session := helpers .CF ("curl" , "-d" , jsonBody , "-X" , "POST" , "/v3/stacks" )
136- Eventually (session ).Should (Exit (0 ))
137-
138- r := regexp .MustCompile (`[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}` )
139- stackGUID = string (r .Find (session .Out .Contents ()))
140- })
141-
142- AfterEach (func () {
143- session := helpers .CF ("curl" , "-X" , "DELETE" , fmt .Sprintf ("/v3/stacks/%s" , stackGUID ))
144- Eventually (session ).Should (Exit (0 ))
145- })
115+ AfterEach (func () {
116+ session := helpers .CF ("curl" , "-X" , "DELETE" , fmt .Sprintf ("/v3/stacks/%s" , stackGUID ))
117+ Eventually (session ).Should (Exit (0 ))
118+ })
146119
147- It ("Shows the details for the stack with state" , func () {
148- session := helpers .CF ("stack" , stackName )
120+ It ("Shows the details for the stack with state" , func () {
121+ session := helpers .CF ("stack" , stackName )
149122
150- Eventually (session ).Should (Say (`Getting info for stack %s as %s\.\.\.` , stackName , username ))
151- Eventually (session ).Should (Say (`name:\s+%s` , stackName ))
152- Eventually (session ).Should (Say (`description:\s+%s` , stackDescription ))
153- Eventually (session ).Should (Say (`state:\s+ACTIVE` ))
154- Eventually (session ).Should (Exit (0 ))
155- })
123+ Eventually (session ).Should (Say (`Getting info for stack %s as %s\.\.\.` , stackName , username ))
124+ Eventually (session ).Should (Say (`name:\s+%s` , stackName ))
125+ Eventually (session ).Should (Say (`description:\s+%s` , stackDescription ))
126+ Eventually (session ).Should (Say (`state:\s+ACTIVE` ))
127+ Eventually (session ).Should (Exit (0 ))
156128 })
157129
158- When ("the stack exists and the --guid flag is passed" , func () {
159- It ("prints nothing but the guid" , func () {
160- session := helpers .CF ("stack" , stackName , "--guid" )
130+ It ("prints nothing but the guid when --guid flag is passed" , func () {
131+ session := helpers .CF ("stack" , stackName , "--guid" )
161132
162- Consistently (session ).ShouldNot (Say (`Getting info for stack %s as %s\.\.\.` , stackName , username ))
163- Consistently (session ).ShouldNot (Say (`name:\s+%s` , stackName ))
164- Consistently (session ).ShouldNot (Say (`description:\s+%s` , stackDescription ))
165- Eventually (session ).Should (Say (`^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12} ` ))
166- Eventually (session ).Should (Exit ( 0 ))
167- } )
133+ Consistently (session ).ShouldNot (Say (`Getting info for stack %s as %s\.\.\.` , stackName , username ))
134+ Consistently (session ).ShouldNot (Say (`name:\s+%s` , stackName ))
135+ Consistently (session ).ShouldNot (Say (`description:\s+%s` , stackDescription ))
136+ Consistently (session ).ShouldNot (Say (`state: ` ))
137+ Eventually (session ).Should (Say ( `^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}` ))
138+ Eventually ( session ). Should ( Exit ( 0 ) )
168139 })
169140 })
170141 })
0 commit comments