@@ -69,7 +69,7 @@ var _ = Describe("Stack", func() {
6969
7070 Context ("there are no errors" , func () {
7171
72- When ("the stack exists" , func () {
72+ When ("the stack exists without state " , func () {
7373 expectedStack := resources.Stack {
7474 GUID : "some-stack-guid" ,
7575 Name : "some-stack-name" ,
@@ -98,6 +98,43 @@ var _ = Describe("Stack", func() {
9898 Expect (stack .GUID ).To (Equal (expectedStack .GUID ))
9999 Expect (stack .Name ).To (Equal (expectedStack .Name ))
100100 Expect (stack .Description ).To (Equal (expectedStack .Description ))
101+ Expect (stack .State ).To (Equal ("" ))
102+ Expect (err ).To (BeNil ())
103+ Expect (warnings ).To (ConsistOf ("warning-1" , "warning-2" ))
104+ })
105+ })
106+
107+ When ("the stack exists with state" , func () {
108+ expectedStack := resources.Stack {
109+ GUID : "some-stack-guid" ,
110+ Name : "some-stack-name" ,
111+ Description : "Some stack desc" ,
112+ State : "ACTIVE" ,
113+ }
114+
115+ expectedParams := []ccv3.Query {
116+ {Key : ccv3 .NameFilter , Values : []string {"some-stack-name" }},
117+ {Key : ccv3 .PerPage , Values : []string {"1" }},
118+ {Key : ccv3 .Page , Values : []string {"1" }},
119+ }
120+
121+ BeforeEach (func () {
122+ fakeCloudControllerClient .GetStacksReturns (
123+ []resources.Stack {expectedStack },
124+ ccv3.Warnings {"warning-1" , "warning-2" },
125+ nil ,
126+ )
127+ })
128+
129+ It ("returns the desired stack with state" , func () {
130+
131+ actualParams := fakeCloudControllerClient .GetStacksArgsForCall (0 )
132+ Expect (actualParams ).To (Equal (expectedParams ))
133+ Expect (fakeCloudControllerClient .GetStacksCallCount ()).To (Equal (1 ))
134+ Expect (stack .GUID ).To (Equal (expectedStack .GUID ))
135+ Expect (stack .Name ).To (Equal (expectedStack .Name ))
136+ Expect (stack .Description ).To (Equal (expectedStack .Description ))
137+ Expect (stack .State ).To (Equal (resources .StackStateActive ))
101138 Expect (err ).To (BeNil ())
102139 Expect (warnings ).To (ConsistOf ("warning-1" , "warning-2" ))
103140 })
@@ -196,4 +233,72 @@ var _ = Describe("Stack", func() {
196233 })
197234 })
198235 })
236+
237+ Describe ("UpdateStack" , func () {
238+ var (
239+ stackGUID string
240+ state string
241+ reason string
242+ stack resources.Stack
243+ warnings Warnings
244+ executeErr error
245+ )
246+
247+ BeforeEach (func () {
248+ stackGUID = "some-stack-guid"
249+ state = "DEPRECATED"
250+ reason = ""
251+ })
252+
253+ JustBeforeEach (func () {
254+ stack , warnings , executeErr = actor .UpdateStack (stackGUID , state , reason )
255+ })
256+
257+ When ("the cloud controller request is successful" , func () {
258+ BeforeEach (func () {
259+ fakeCloudControllerClient .UpdateStackReturns (
260+ resources.Stack {
261+ GUID : "some-stack-guid" ,
262+ Name : "some-stack" ,
263+ Description : "some description" ,
264+ State : "DEPRECATED" ,
265+ },
266+ ccv3.Warnings {"warning-1" , "warning-2" },
267+ nil ,
268+ )
269+ })
270+
271+ It ("returns the updated stack and warnings" , func () {
272+ Expect (executeErr ).ToNot (HaveOccurred ())
273+ Expect (warnings ).To (ConsistOf ("warning-1" , "warning-2" ))
274+ Expect (stack ).To (Equal (resources.Stack {
275+ GUID : "some-stack-guid" ,
276+ Name : "some-stack" ,
277+ Description : "some description" ,
278+ State : "DEPRECATED" ,
279+ }))
280+
281+ Expect (fakeCloudControllerClient .UpdateStackCallCount ()).To (Equal (1 ))
282+ actualGUID , actualState , actualReason := fakeCloudControllerClient .UpdateStackArgsForCall (0 )
283+ Expect (actualGUID ).To (Equal (stackGUID ))
284+ Expect (actualState ).To (Equal (state ))
285+ Expect (actualReason ).To (Equal (reason ))
286+ })
287+ })
288+
289+ When ("the cloud controller request fails" , func () {
290+ BeforeEach (func () {
291+ fakeCloudControllerClient .UpdateStackReturns (
292+ resources.Stack {},
293+ ccv3.Warnings {"warning-1" },
294+ errors .New ("some-error" ),
295+ )
296+ })
297+
298+ It ("returns the error and warnings" , func () {
299+ Expect (executeErr ).To (MatchError ("some-error" ))
300+ Expect (warnings ).To (ConsistOf ("warning-1" ))
301+ })
302+ })
303+ })
199304})
0 commit comments