Skip to content

Commit

Permalink
Fixing up the acceptance test
Browse files Browse the repository at this point in the history
  • Loading branch information
Shocktrooper committed Apr 3, 2022
1 parent 8348b00 commit b7ea5da
Showing 1 changed file with 14 additions and 23 deletions.
37 changes: 14 additions & 23 deletions internal/provider/resource_gitlab_group_share_group_test.go
Expand Up @@ -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,
},
},
})
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -148,7 +143,3 @@ func testAccGitlabGroupShareGroupConfig(mainGroupId int, shareGroupId int, share
shareGroupSettings,
)
}

func testAccGitlabGroupShareGroupConfigDelete() string {
return ``
}

0 comments on commit b7ea5da

Please sign in to comment.