Skip to content

Commit

Permalink
Reverted and refactored some acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Shocktrooper committed Apr 24, 2022
1 parent 8348b00 commit f3e1194
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 27 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 ``
}
12 changes: 8 additions & 4 deletions internal/provider/resource_gitlab_project_test.go
Expand Up @@ -662,7 +662,8 @@ func TestAccGitlabProject_willErrorOnAPIFailure(t *testing.T) {
})
}

func TestAccGitlabProject_imprt(t *testing.T) {
// lintignore: AT002 // specialized import test
func TestAccGitlabProject_import(t *testing.T) {
rInt := acctest.RandInt()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand All @@ -686,7 +687,8 @@ func TestAccGitlabProject_imprt(t *testing.T) {
})
}

func TestAccGitlabProject_nestedImprt(t *testing.T) {
// lintignore: AT002 // specialized import test
func TestAccGitlabProject_nestedImport(t *testing.T) {
rInt := acctest.RandInt()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Expand Down Expand Up @@ -766,7 +768,8 @@ func TestAccGitlabProject_transfer(t *testing.T) {
})
}

func TestAccGitlabProject_imprtURL(t *testing.T) {
// lintignore: AT002 // not a Terraform import test
func TestAccGitlabProject_importURL(t *testing.T) {
testAccCheck(t)

rInt := acctest.RandInt()
Expand Down Expand Up @@ -890,7 +893,8 @@ func testAccCheckGitlabProjectMirroredAttributes(project *gitlab.Project, want *
}
}

func TestAccGitlabProject_ImprtURLMirrored(t *testing.T) {
// lintignore: AT002 // not a Terraform import test
func TestAccGitlabProject_ImportURLMirrored(t *testing.T) {
testAccCheck(t)

var mirror gitlab.Project
Expand Down

0 comments on commit f3e1194

Please sign in to comment.