Skip to content

Commit 8bd9c00

Browse files
committed
test that group id of nested group does not change after transfer to another parent group
1 parent 8d2687a commit 8bd9c00

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

internal/provider/resource_gitlab_group_test.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,16 @@ func TestAccGitlabGroup_nested(t *testing.T) {
134134
var group gitlab.Group
135135
var group2 gitlab.Group
136136
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+
}
137147
rInt := acctest.RandInt()
138148

139149
resource.Test(t, resource.TestCase{
@@ -157,8 +167,8 @@ func TestAccGitlabGroup_nested(t *testing.T) {
157167
TwoFactorGracePeriod: 48, // default value
158168
DefaultBranchProtection: 2, // default value
159169
Parent: &group,
160-
AutoDevopsEnabled: true,
161170
}),
171+
testGidNotChanged,
162172
),
163173
},
164174
{
@@ -178,8 +188,8 @@ func TestAccGitlabGroup_nested(t *testing.T) {
178188
TwoFactorGracePeriod: 48, // default value
179189
DefaultBranchProtection: 2, // default value
180190
Parent: &group2,
181-
AutoDevopsEnabled: true,
182191
}),
192+
testGidNotChanged,
183193
),
184194
},
185195
{
@@ -199,6 +209,7 @@ func TestAccGitlabGroup_nested(t *testing.T) {
199209
TwoFactorGracePeriod: 48, // default value
200210
DefaultBranchProtection: 2, // default value
201211
}),
212+
testGidNotChanged,
202213
),
203214
},
204215
{
@@ -219,6 +230,7 @@ func TestAccGitlabGroup_nested(t *testing.T) {
219230
DefaultBranchProtection: 2, // default value
220231
Parent: &group,
221232
}),
233+
testGidNotChanged,
222234
),
223235
},
224236
},
@@ -503,12 +515,6 @@ resource "gitlab_group" "nested_foo" {
503515
# So that acceptance tests can be run in a gitlab organization
504516
# with no billing
505517
visibility_level = "public"
506-
507-
# We set this to a non-default value to check later whether the group was recreated or not
508-
auto_devops_enabled = true
509-
lifecycle {
510-
ignore_changes = [auto_devops_enabled]
511-
}
512518
}
513519
`, rInt, rInt, rInt, rInt, rInt, rInt)
514520
}
@@ -574,11 +580,6 @@ resource "gitlab_group" "nested_foo" {
574580
# So that acceptance tests can be run in a gitlab organization
575581
# with no billing
576582
visibility_level = "public"
577-
578-
# We need to read this value to check if the group is recreated or not
579-
lifecycle {
580-
ignore_changes = [auto_devops_enabled]
581-
}
582583
}
583584
`, rInt, rInt, rInt, rInt, rInt, rInt)
584585
}

0 commit comments

Comments
 (0)