From b7ea5dae32ac0233628552cd12e9c4fc7fd8238a Mon Sep 17 00:00:00 2001 From: Shocktrooper Date: Sun, 3 Apr 2022 21:14:14 +0000 Subject: [PATCH] Fixing up the acceptance test --- .../resource_gitlab_group_share_group_test.go | 37 +++++++------------ 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/internal/provider/resource_gitlab_group_share_group_test.go b/internal/provider/resource_gitlab_group_share_group_test.go index af19bf9d6..e07ac57de 100644 --- a/internal/provider/resource_gitlab_group_share_group_test.go +++ b/internal/provider/resource_gitlab_group_share_group_test.go @@ -47,10 +47,21 @@ func TestAccGitlabGroupShareGroup_basic(t *testing.T) { ImportState: true, ImportStateVerify: true, }, - // Delete the gitlab_group_share_group resource + // Update share group back to initial settings { - Config: testAccGitlabGroupShareGroupConfigDelete(), - Check: testAccCheckGitlabGroupIsNotShared(mainGroup.Name), + Config: testAccGitlabGroupShareGroupConfig(mainGroup.ID, sharedGroup.ID, + ` + group_access = "guest" + expires_at = "2099-01-01" + `, + ), + Check: testAccCheckGitlabGroupSharedWithGroup(mainGroup.Name, sharedGroup.Name, "2099-01-01", gitlab.GuestPermissions), + }, + { + // Verify Import + ResourceName: "gitlab_group_share_group.test", + ImportState: true, + ImportStateVerify: true, }, }, }) @@ -88,22 +99,6 @@ func testAccCheckGitlabGroupSharedWithGroup(mainGroupName string, sharedGroupNam } } -func testAccCheckGitlabGroupIsNotShared(mainGroupName string) resource.TestCheckFunc { - return func(_ *terraform.State) error { - mainGroup, _, err := testGitlabClient.Groups.GetGroup(mainGroupName, nil) - if err != nil { - return err - } - - sharedGroupsCount := len(mainGroup.SharedWithGroups) - if sharedGroupsCount != 0 { - return fmt.Errorf("Number of shared groups was %d (wanted %d)", sharedGroupsCount, 0) - } - - return nil - } -} - func testAccCheckGitlabShareGroupDestroy(s *terraform.State) error { var groupId string var sharedGroupId int @@ -148,7 +143,3 @@ func testAccGitlabGroupShareGroupConfig(mainGroupId int, shareGroupId int, share shareGroupSettings, ) } - -func testAccGitlabGroupShareGroupConfigDelete() string { - return `` -}