@@ -124,3 +124,50 @@ func TestStackDeploymentGroupsRead(t *testing.T) {
124
124
require .Error (t , err )
125
125
})
126
126
}
127
+
128
+ func TestStackDeploymentGroupsApproveAllPlans (t * testing.T ) {
129
+ skipUnlessBeta (t )
130
+
131
+ client := testClient (t )
132
+ ctx := context .Background ()
133
+
134
+ orgTest , orgTestCleanup := createOrganization (t , client )
135
+ t .Cleanup (orgTestCleanup )
136
+
137
+ oauthClient , cleanup := createOAuthClient (t , client , orgTest , nil )
138
+ t .Cleanup (cleanup )
139
+
140
+ stack , err := client .Stacks .Create (ctx , StackCreateOptions {
141
+ Name : "test-stack" ,
142
+ VCSRepo : & StackVCSRepoOptions {
143
+ Identifier : "hashicorp-guides/pet-nulls-stack" ,
144
+ OAuthTokenID : oauthClient .OAuthTokens [0 ].ID ,
145
+ Branch : "main" ,
146
+ },
147
+ Project : & Project {
148
+ ID : orgTest .DefaultProject .ID ,
149
+ },
150
+ })
151
+ require .NoError (t , err )
152
+ require .NotNil (t , stack )
153
+
154
+ stackUpdated , err := client .Stacks .UpdateConfiguration (ctx , stack .ID )
155
+ require .NoError (t , err )
156
+ require .NotNil (t , stackUpdated )
157
+
158
+ stack = pollStackDeployments (t , ctx , client , stackUpdated .ID )
159
+ require .NotNil (t , stack .LatestStackConfiguration )
160
+
161
+ // Get the deployment group ID from the stack configuration
162
+ deploymentGroups , err := client .StackDeploymentGroups .List (ctx , stack .LatestStackConfiguration .ID , nil )
163
+ require .NoError (t , err )
164
+ require .NotNil (t , deploymentGroups )
165
+ require .NotEmpty (t , deploymentGroups .Items )
166
+
167
+ deploymentGroupID := deploymentGroups .Items [0 ].ID
168
+
169
+ t .Run ("Approve all plans" , func (t * testing.T ) {
170
+ err := client .StackDeploymentGroups .ApproveAllPlans (ctx , deploymentGroupID )
171
+ require .NoError (t , err )
172
+ })
173
+ }
0 commit comments