@@ -13,6 +13,8 @@ func TestStacks(t *testing.T) {
1313 g := testutil .NewObjectJSONGenerator ()
1414 stack := g .Stack ().JSON
1515 stack2 := g .Stack ().JSON
16+ stackWithState := g .StackWithState ("ACTIVE" , "Stack is fully available" ).JSON
17+ stackWithState2 := g .StackWithState ("DEPRECATED" , "Stack deprecated and will be removed" ).JSON
1618 app := g .Application ().JSON
1719 app2 := g .Application ().JSON
1820
@@ -36,6 +38,29 @@ func TestStacks(t *testing.T) {
3638 return c .Stacks .Create (context .Background (), r )
3739 },
3840 },
41+ {
42+ Description : "Create stack with state" ,
43+ Route : testutil.MockRoute {
44+ Method : "POST" ,
45+ Endpoint : "/v3/stacks" ,
46+ Output : g .Single (stackWithState ),
47+ Status : http .StatusCreated ,
48+ PostForm : `{ "name": "my-stack", "description": "Here is my stack!", "state": "ACTIVE", "state_reason": "Stack is fully available" }` ,
49+ },
50+ Expected : stackWithState ,
51+ Action : func (c * Client , t * testing.T ) (any , error ) {
52+ stackDescription := "Here is my stack!"
53+ stackState := "ACTIVE"
54+ stackStateReason := "Stack is fully available"
55+ r := & resource.StackCreate {
56+ Name : "my-stack" ,
57+ Description : & stackDescription ,
58+ State : & stackState ,
59+ StateReason : & stackStateReason ,
60+ }
61+ return c .Stacks .Create (context .Background (), r )
62+ },
63+ },
3964 {
4065 Description : "Delete stack" ,
4166 Route : testutil.MockRoute {
@@ -59,6 +84,18 @@ func TestStacks(t *testing.T) {
5984 return c .Stacks .Get (context .Background (), "88db2b75-671f-4e4b-a19a-7db992366595" )
6085 },
6186 },
87+ {
88+ Description : "Get stack with state" ,
89+ Route : testutil.MockRoute {
90+ Method : "GET" ,
91+ Endpoint : "/v3/stacks/88db2b75-671f-4e4b-a19a-7db992366595" ,
92+ Output : g .Single (stackWithState ),
93+ Status : http .StatusOK },
94+ Expected : stackWithState ,
95+ Action : func (c * Client , t * testing.T ) (any , error ) {
96+ return c .Stacks .Get (context .Background (), "88db2b75-671f-4e4b-a19a-7db992366595" )
97+ },
98+ },
6299 {
63100 Description : "List all stacks" ,
64101 Route : testutil.MockRoute {
@@ -71,6 +108,18 @@ func TestStacks(t *testing.T) {
71108 return c .Stacks .ListAll (context .Background (), nil )
72109 },
73110 },
111+ {
112+ Description : "List all stacks with state" ,
113+ Route : testutil.MockRoute {
114+ Method : "GET" ,
115+ Endpoint : "/v3/stacks" ,
116+ Output : g .Paged ([]string {stackWithState }, []string {stackWithState2 }),
117+ Status : http .StatusOK },
118+ Expected : g .Array (stackWithState , stackWithState2 ),
119+ Action : func (c * Client , t * testing.T ) (any , error ) {
120+ return c .Stacks .ListAll (context .Background (), nil )
121+ },
122+ },
74123 {
75124 Description : "List all apps for given stack" ,
76125 Route : testutil.MockRoute {
@@ -102,6 +151,26 @@ func TestStacks(t *testing.T) {
102151 return c .Stacks .Update (context .Background (), "88db2b75-671f-4e4b-a19a-7db992366595" , r )
103152 },
104153 },
154+ {
155+ Description : "Update stack state" ,
156+ Route : testutil.MockRoute {
157+ Method : "PATCH" ,
158+ Endpoint : "/v3/stacks/88db2b75-671f-4e4b-a19a-7db992366595" ,
159+ Output : g .Single (stackWithState2 ),
160+ Status : http .StatusOK ,
161+ PostForm : `{ "state": "DEPRECATED", "state_reason": "Stack deprecated and will be removed" }` ,
162+ },
163+ Expected : stackWithState2 ,
164+ Action : func (c * Client , t * testing.T ) (any , error ) {
165+ state := "DEPRECATED"
166+ stateReason := "Stack deprecated and will be removed"
167+ r := & resource.StackUpdate {
168+ State : & state ,
169+ StateReason : & stateReason ,
170+ }
171+ return c .Stacks .Update (context .Background (), "88db2b75-671f-4e4b-a19a-7db992366595" , r )
172+ },
173+ },
105174 }
106175 ExecuteTests (tests , t )
107176}
0 commit comments