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 `` -} diff --git a/internal/provider/resource_gitlab_project_test.go b/internal/provider/resource_gitlab_project_test.go index 04a4021ee..344a90c48 100644 --- a/internal/provider/resource_gitlab_project_test.go +++ b/internal/provider/resource_gitlab_project_test.go @@ -662,31 +662,8 @@ func TestAccGitlabProject_willErrorOnAPIFailure(t *testing.T) { }) } -func TestAccGitlabProject_imprt(t *testing.T) { - rInt := acctest.RandInt() - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - ProviderFactories: providerFactories, - CheckDestroy: testAccCheckGitlabProjectDestroy, - Steps: []resource.TestStep{ - { - SkipFunc: isRunningInEE, - Config: testAccGitlabProjectConfig(rInt), - }, - { - SkipFunc: isRunningInCE, - Config: testAccGitlabProjectConfigEE(rInt), - }, - { - ResourceName: "gitlab_project.foo", - ImportState: true, - ImportStateVerify: true, - }, - }, - }) -} - -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) }, @@ -766,7 +743,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() @@ -890,7 +868,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