From 45a79cd3f6553911fe305c998b2a0ef5d0c79b79 Mon Sep 17 00:00:00 2001 From: Shocktrooper Date: Thu, 31 Mar 2022 11:40:56 -0500 Subject: [PATCH] Review comments --- GNUmakefile | 2 +- .../resource_gitlab_group_share_group_test.go | 23 ++++++++++--------- ...esource_gitlab_project_share_group_test.go | 18 +++++++-------- .../provider/resource_gitlab_project_test.go | 10 ++------ 4 files changed, 24 insertions(+), 29 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 38d7948e1..0ab04394b 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -20,7 +20,7 @@ endif test: ## Run unit tests. go test $(TESTARGS) $(PROVIDER_SRC_DIR) -TFPROVIDERLINTX_CHECKS = -XAT001=false -XR003=false -XS002=false +TFPROVIDERLINTX_CHECKS = -XR003=false -XS002=false fmt: tool-golangci-lint tool-tfproviderlintx tool-terraform tool-shfmt ## Format files and fix issues. gofmt -w -s . diff --git a/internal/provider/resource_gitlab_group_share_group_test.go b/internal/provider/resource_gitlab_group_share_group_test.go index fa4252a0f..af19bf9d6 100644 --- a/internal/provider/resource_gitlab_group_share_group_test.go +++ b/internal/provider/resource_gitlab_group_share_group_test.go @@ -115,21 +115,22 @@ func testAccCheckGitlabShareGroupDestroy(s *terraform.State) error { if err != nil { return fmt.Errorf("[ERROR] cannot get Group ID and ShareGroupId from input: %v", rs.Primary.ID) } - } - } - // Get Main Group - group, _, err := testGitlabClient.Groups.GetGroup(groupId, nil) - if err != nil { - return err - } + // Get Main Group + group, _, err := testGitlabClient.Groups.GetGroup(groupId, nil) + if err != nil { + return err + } - // Make sure that SharedWithGroups attribute on the main group does not contain the shared group id at all - for _, sharedGroup := range group.SharedWithGroups { - if sharedGroupId == sharedGroup.GroupID { - return fmt.Errorf("GitLab Group Share %d still exists", sharedGroupId) + // Make sure that SharedWithGroups attribute on the main group does not contain the shared group id at all + for _, sharedGroup := range group.SharedWithGroups { + if sharedGroupId == sharedGroup.GroupID { + return fmt.Errorf("GitLab Group Share %d still exists", sharedGroupId) + } + } } } + return nil } diff --git a/internal/provider/resource_gitlab_project_share_group_test.go b/internal/provider/resource_gitlab_project_share_group_test.go index 2b06aa961..72760282c 100644 --- a/internal/provider/resource_gitlab_project_share_group_test.go +++ b/internal/provider/resource_gitlab_project_share_group_test.go @@ -120,17 +120,17 @@ func testAccCheckGitlabProjectShareGroupDestroy(s *terraform.State) error { if err != nil { return fmt.Errorf("[ERROR] cannot get project ID and group ID from input: %v", rs.Primary.ID) } - } - } - proj, _, err := testGitlabClient.Projects.GetProject(projectId, nil) - if err != nil { - return err - } + proj, _, err := testGitlabClient.Projects.GetProject(projectId, nil) + if err != nil { + return err + } - for _, v := range proj.SharedWithGroups { - if groupId == v.GroupID { - return fmt.Errorf("GitLab Project Share %d still exists", groupId) + for _, v := range proj.SharedWithGroups { + if groupId == v.GroupID { + return fmt.Errorf("GitLab Project Share %d still exists", groupId) + } + } } } diff --git a/internal/provider/resource_gitlab_project_test.go b/internal/provider/resource_gitlab_project_test.go index 415be44e3..c834a8a9f 100644 --- a/internal/provider/resource_gitlab_project_test.go +++ b/internal/provider/resource_gitlab_project_test.go @@ -768,10 +768,7 @@ func TestAccGitlabProject_transfer(t *testing.T) { } func TestAccGitlabProject_imprtURL(t *testing.T) { - // Since we do some manual setup in this test, we need to handle the test skip first. - if os.Getenv(resource.EnvTfAcc) == "" { - t.Skip(fmt.Sprintf("Acceptance tests skipped unless env '%s' set", resource.EnvTfAcc)) - } + testAccCheck(t) rInt := acctest.RandInt() @@ -895,10 +892,7 @@ func testAccCheckGitlabProjectMirroredAttributes(project *gitlab.Project, want * } func TestAccGitlabProject_ImprtURLMirrored(t *testing.T) { - // Since we do some manual setup in this test, we need to handle the test skip first. - if os.Getenv(resource.EnvTfAcc) == "" { - t.Skip(fmt.Sprintf("Acceptance tests skipped unless env '%s' set", resource.EnvTfAcc)) - } + testAccCheck(t) var mirror gitlab.Project rInt := acctest.RandInt()