@@ -47,10 +47,21 @@ func TestAccGitlabGroupShareGroup_basic(t *testing.T) {
47
47
ImportState : true ,
48
48
ImportStateVerify : true ,
49
49
},
50
- // Delete the gitlab_group_share_group resource
50
+ // Update share group back to initial settings
51
51
{
52
- Config : testAccGitlabGroupShareGroupConfigDelete (),
53
- Check : testAccCheckGitlabGroupIsNotShared (mainGroup .Name ),
52
+ Config : testAccGitlabGroupShareGroupConfig (mainGroup .ID , sharedGroup .ID ,
53
+ `
54
+ group_access = "guest"
55
+ expires_at = "2099-01-01"
56
+ ` ,
57
+ ),
58
+ Check : testAccCheckGitlabGroupSharedWithGroup (mainGroup .Name , sharedGroup .Name , "2099-01-01" , gitlab .GuestPermissions ),
59
+ },
60
+ {
61
+ // Verify Import
62
+ ResourceName : "gitlab_group_share_group.test" ,
63
+ ImportState : true ,
64
+ ImportStateVerify : true ,
54
65
},
55
66
},
56
67
})
@@ -88,22 +99,6 @@ func testAccCheckGitlabGroupSharedWithGroup(mainGroupName string, sharedGroupNam
88
99
}
89
100
}
90
101
91
- func testAccCheckGitlabGroupIsNotShared (mainGroupName string ) resource.TestCheckFunc {
92
- return func (_ * terraform.State ) error {
93
- mainGroup , _ , err := testGitlabClient .Groups .GetGroup (mainGroupName , nil )
94
- if err != nil {
95
- return err
96
- }
97
-
98
- sharedGroupsCount := len (mainGroup .SharedWithGroups )
99
- if sharedGroupsCount != 0 {
100
- return fmt .Errorf ("Number of shared groups was %d (wanted %d)" , sharedGroupsCount , 0 )
101
- }
102
-
103
- return nil
104
- }
105
- }
106
-
107
102
func testAccCheckGitlabShareGroupDestroy (s * terraform.State ) error {
108
103
var groupId string
109
104
var sharedGroupId int
@@ -148,7 +143,3 @@ func testAccGitlabGroupShareGroupConfig(mainGroupId int, shareGroupId int, share
148
143
shareGroupSettings ,
149
144
)
150
145
}
151
-
152
- func testAccGitlabGroupShareGroupConfigDelete () string {
153
- return ``
154
- }
0 commit comments