@@ -134,6 +134,16 @@ func TestAccGitlabGroup_nested(t *testing.T) {
134
134
var group gitlab.Group
135
135
var group2 gitlab.Group
136
136
var nestedGroup gitlab.Group
137
+ var lastGid int
138
+ testGidNotChanged := func (s * terraform.State ) error {
139
+ if lastGid == 0 {
140
+ lastGid = nestedGroup .ID
141
+ }
142
+ if lastGid != nestedGroup .ID {
143
+ return fmt .Errorf ("group id changed" )
144
+ }
145
+ return nil
146
+ }
137
147
rInt := acctest .RandInt ()
138
148
139
149
resource .Test (t , resource.TestCase {
@@ -158,6 +168,7 @@ func TestAccGitlabGroup_nested(t *testing.T) {
158
168
DefaultBranchProtection : 2 , // default value
159
169
Parent : & group ,
160
170
}),
171
+ testGidNotChanged ,
161
172
),
162
173
},
163
174
{
@@ -178,6 +189,7 @@ func TestAccGitlabGroup_nested(t *testing.T) {
178
189
DefaultBranchProtection : 2 , // default value
179
190
Parent : & group2 ,
180
191
}),
192
+ testGidNotChanged ,
181
193
),
182
194
},
183
195
{
@@ -197,29 +209,30 @@ func TestAccGitlabGroup_nested(t *testing.T) {
197
209
TwoFactorGracePeriod : 48 , // default value
198
210
DefaultBranchProtection : 2 , // default value
199
211
}),
212
+ testGidNotChanged ,
213
+ ),
214
+ },
215
+ {
216
+ Config : testAccGitlabNestedGroupConfig (rInt ),
217
+ Check : resource .ComposeTestCheckFunc (
218
+ testAccCheckGitlabGroupExists ("gitlab_group.foo" , & group ),
219
+ testAccCheckGitlabGroupExists ("gitlab_group.foo2" , & group2 ),
220
+ testAccCheckGitlabGroupExists ("gitlab_group.nested_foo" , & nestedGroup ),
221
+ testAccCheckGitlabGroupAttributes (& nestedGroup , & testAccGitlabGroupExpectedAttributes {
222
+ Name : fmt .Sprintf ("nfoo-name-%d" , rInt ),
223
+ Path : fmt .Sprintf ("nfoo-path-%d" , rInt ),
224
+ Description : "Terraform acceptance tests" ,
225
+ LFSEnabled : true ,
226
+ Visibility : "public" , // default value
227
+ ProjectCreationLevel : "maintainer" , // default value
228
+ SubGroupCreationLevel : "owner" , // default value
229
+ TwoFactorGracePeriod : 48 , // default value
230
+ DefaultBranchProtection : 2 , // default value
231
+ Parent : & group ,
232
+ }),
233
+ testGidNotChanged ,
200
234
),
201
235
},
202
- // TODO In EE version, re-creating on the same path where a previous group was soft-deleted doesn't work.
203
- // {
204
- // Config: testAccGitlabNestedGroupConfig(rInt),
205
- // Check: resource.ComposeTestCheckFunc(
206
- // testAccCheckGitlabGroupExists("gitlab_group.foo", &group),
207
- // testAccCheckGitlabGroupExists("gitlab_group.foo2", &group2),
208
- // testAccCheckGitlabGroupExists("gitlab_group.nested_foo", &nestedGroup),
209
- // testAccCheckGitlabGroupAttributes(&nestedGroup, &testAccGitlabGroupExpectedAttributes{
210
- // Name: fmt.Sprintf("nfoo-name-%d", rInt),
211
- // Path: fmt.Sprintf("nfoo-path-%d", rInt),
212
- // Description: "Terraform acceptance tests",
213
- // LFSEnabled: true,
214
- // Visibility: "public", // default value
215
- // ProjectCreationLevel: "maintainer", // default value
216
- // SubGroupCreationLevel: "owner", // default value
217
- // TwoFactorGracePeriod: 48, // default value
218
- // DefaultBranchProtection: 2, // default value
219
- // Parent: &group,
220
- // }),
221
- // ),
222
- // },
223
236
},
224
237
})
225
238
}
0 commit comments