@@ -19,13 +19,19 @@ func TestAccGitlabGroupShareGroup_basic(t *testing.T) {
19
19
Steps : []resource.TestStep {
20
20
// Share a new group with another group
21
21
{
22
- Config : testAccGitlabGroupShareGroupConfig (randName , "guest" , "2099-01-01" ),
23
- Check : testAccCheckGitlabGroupSharedWithGroup (randName , "2099-01-01" , gitlab .GuestPermissions ),
22
+ Config : testAccGitlabGroupShareGroupConfig (
23
+ randName ,
24
+ `
25
+ group_access = "guest"
26
+ expires_at = "2099-01-01"
27
+ ` ,
28
+ ),
29
+ Check : testAccCheckGitlabGroupSharedWithGroup (randName , "2099-01-01" , gitlab .GuestPermissions ),
24
30
},
25
31
// Update the share group
26
32
{
27
- Config : testAccGitlabGroupShareGroupConfig (randName , "reporter" , "2099-02-02" ),
28
- Check : testAccCheckGitlabGroupSharedWithGroup (randName , "2099-02-02 " , gitlab .ReporterPermissions ),
33
+ Config : testAccGitlabGroupShareGroupConfig (randName , `group_access = "reporter"` ),
34
+ Check : testAccCheckGitlabGroupSharedWithGroup (randName , "" , gitlab .ReporterPermissions ),
29
35
},
30
36
// Delete the gitlab_group_share_group resource
31
37
{
@@ -46,8 +52,14 @@ func TestAccGitlabGroupShareGroup_import(t *testing.T) {
46
52
Steps : []resource.TestStep {
47
53
{
48
54
// create shared groups
49
- Config : testAccGitlabGroupShareGroupConfig (randName , "guest" , "2099-03-03" ),
50
- Check : testAccCheckGitlabGroupSharedWithGroup (randName , "2099-03-03" , gitlab .GuestPermissions ),
55
+ Config : testAccGitlabGroupShareGroupConfig (
56
+ randName ,
57
+ `
58
+ group_access = "guest"
59
+ expires_at = "2099-03-03"
60
+ ` ,
61
+ ),
62
+ Check : testAccCheckGitlabGroupSharedWithGroup (randName , "2099-03-03" , gitlab .GuestPermissions ),
51
63
},
52
64
{
53
65
// Verify Import
@@ -87,8 +99,10 @@ func testAccCheckGitlabGroupSharedWithGroup(
87
99
return fmt .Errorf ("groupAccessLevel was %d (wanted %d)" , sharedGroup .GroupAccessLevel , accessLevel )
88
100
}
89
101
90
- if sharedGroup .ExpiresAt .String () != expireTime {
91
- return fmt .Errorf ("expired time was %s (wanted %s)" , sharedGroup .ExpiresAt .String (), expireTime )
102
+ if sharedGroup .ExpiresAt == nil && expireTime != "" {
103
+ return fmt .Errorf ("expire time was nil (wanted %s)" , expireTime )
104
+ } else if sharedGroup .ExpiresAt != nil && sharedGroup .ExpiresAt .String () != expireTime {
105
+ return fmt .Errorf ("expire time was %s (wanted %s)" , sharedGroup .ExpiresAt .String (), expireTime )
92
106
}
93
107
94
108
return nil
@@ -115,8 +129,7 @@ func testAccCheckGitlabGroupIsNotShared(groupName string) resource.TestCheckFunc
115
129
116
130
func testAccGitlabGroupShareGroupConfig (
117
131
randName string ,
118
- accessLevel string ,
119
- expireTime string ,
132
+ shareGroupSettings string ,
120
133
) string {
121
134
return fmt .Sprintf (
122
135
`
@@ -133,13 +146,11 @@ func testAccGitlabGroupShareGroupConfig(
133
146
resource "gitlab_group_share_group" "test" {
134
147
group_id = gitlab_group.test_main.id
135
148
share_group_id = gitlab_group.test_share.id
136
- group_access = "%[2]s"
137
- expires_at = "%[3]s"
149
+ %[2]s
138
150
}
139
151
` ,
140
152
randName ,
141
- accessLevel ,
142
- expireTime ,
153
+ shareGroupSettings ,
143
154
)
144
155
}
145
156
0 commit comments