Skip to content

Commit dafe2b6

Browse files
authored
Merge pull request #1045 from armsnyder/acceptance-tags
Remove test boilerplate by adding build tag
2 parents 145117c + ba1deb4 commit dafe2b6

File tree

85 files changed

+308
-270
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+308
-270
lines changed

.github/workflows/pr-lint.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ jobs:
2828
matrix:
2929
target:
3030
- lint-golangci
31-
- lint-tfprovider
3231
- lint-examples-tf
3332
- lint-examples-sh
3433
- lint-generated

.github/workflows/push.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ jobs:
4040
matrix:
4141
target:
4242
- lint-golangci
43-
- lint-tfprovider
4443
- lint-examples-tf
4544
- lint-examples-sh
4645
- lint-generated

.golangci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@ run:
44
timeout: 3m
55

66
linters-settings:
7+
custom:
8+
tfproviderlint:
9+
path: ./bin/tfproviderlint-plugin.so
10+
description: "Terraform Provider Lint Tool"
11+
original-url: https://github.com/bflad/tfproviderlint
712
errcheck:
813
exclude: errcheck_excludes.txt
914

1015
linters:
1116
enable:
1217
- gofmt
1318
- govet
19+
- tfproviderlint

.vscode/settings.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"go.testEnvVars": {
3-
"TF_ACC": "1",
4-
"GITLAB_TOKEN": "ACCTEST1234567890123",
5-
"GITLAB_BASE_URL": "http://127.0.0.1:8080"
6-
},
7-
"go.testFlags": ["-count=1", "-v", "-timeout=30m"]
2+
"go.testEnvVars": {
3+
"TF_ACC": "1",
4+
"GITLAB_TOKEN": "ACCTEST1234567890123",
5+
"GITLAB_BASE_URL": "http://127.0.0.1:8080"
6+
},
7+
"go.testFlags": ["-count=1", "-v", "-tags=acceptance", "-tags=acceptance"]
88
}

GNUmakefile

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,14 @@ endif
2121
test: ## Run unit tests.
2222
go test $(TESTARGS) $(PROVIDER_SRC_DIR)
2323

24-
TFPROVIDERLINTX_CHECKS = -XAT001=false -XR003=false -XS002=false
25-
26-
fmt: tool-golangci-lint tool-tfproviderlintx tool-terraform tool-shfmt ## Format files and fix issues.
24+
fmt: tool-golangci-lint tool-terraform tool-shfmt tfproviderlint-plugin ## Format files and fix issues.
2725
gofmt -w -s .
28-
$(GOBIN)/golangci-lint run --fix
29-
$(GOBIN)/tfproviderlintx $(TFPROVIDERLINTX_CHECKS) --fix ./...
26+
$(GOBIN)/golangci-lint run --build-tags acceptance --fix
3027
$(GOBIN)/terraform fmt -recursive -list ./examples
3128
$(GOBIN)/shfmt -l -s -w ./examples
3229

33-
lint-golangci: tool-golangci-lint ## Run golangci-lint linter (same as fmt but without modifying files).
34-
$(GOBIN)/golangci-lint run
35-
36-
lint-tfprovider: tool-tfproviderlintx ## Run tfproviderlintx linter (same as fmt but without modifying files).
37-
$(GOBIN)/tfproviderlintx $(TFPROVIDERLINTX_CHECKS) ./...
30+
lint-golangci: tool-golangci-lint tfproviderlint-plugin ## Run golangci-lint linter (same as fmt but without modifying files).
31+
$(GOBIN)/golangci-lint run --build-tags acceptance
3832

3933
lint-examples-tf: tool-terraform ## Run terraform linter on examples (same as fmt but without modifying files).
4034
$(GOBIN)/terraform fmt -recursive -check ./examples
@@ -73,7 +67,7 @@ testacc-down: ## Teardown a GitLab instance.
7367
docker-compose down --volumes
7468

7569
testacc: ## Run acceptance tests against a GitLab instance.
76-
TF_ACC=1 GITLAB_TOKEN=$(GITLAB_TOKEN) GITLAB_BASE_URL=$(GITLAB_BASE_URL) go test -v $(PROVIDER_SRC_DIR) $(TESTARGS) -timeout 40m
70+
TF_ACC=1 GITLAB_TOKEN=$(GITLAB_TOKEN) GITLAB_BASE_URL=$(GITLAB_BASE_URL) go test --tags acceptance -v $(PROVIDER_SRC_DIR) $(TESTARGS) -timeout 40m
7771

7872
certs: ## Generate certs for the GitLab container registry
7973
mkdir -p certs
@@ -85,9 +79,6 @@ certs: ## Generate certs for the GitLab container registry
8579
tool-golangci-lint:
8680
@$(call install-tool, github.com/golangci/golangci-lint/cmd/golangci-lint)
8781

88-
tool-tfproviderlintx:
89-
@$(call install-tool, github.com/bflad/tfproviderlint/cmd/tfproviderlintx)
90-
9182
tool-tfplugindocs:
9283
@$(call install-tool, github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs)
9384

@@ -110,4 +101,7 @@ tool-terraform:
110101
@[ -f $(GOBIN)/terraform ] || { mkdir -p tmp; cd tmp; rm -rf terraform; git clone --branch $(TERRAFORM_VERSION) --depth 1 https://github.com/hashicorp/terraform.git; cd terraform; GOBIN=$(GOBIN) go install; cd ..; rm -rf terraform; }
111102

112103
clean: testacc-down
113-
@rm -rf certs/
104+
@rm -rf certs/
105+
106+
tfproviderlint-plugin:
107+
@cd tools && go build -buildmode=plugin -o $(GOBIN)/tfproviderlint-plugin.so ./cmd/tfproviderlint-plugin

internal/provider/data_source_gitlab_branch_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build acceptance
2+
// +build acceptance
3+
14
package provider
25

36
import (
@@ -11,10 +14,8 @@ import (
1114

1215
func TestAccDataGitlabBranch_basic(t *testing.T) {
1316
rInt := acctest.RandInt()
14-
testAccCheck(t)
1517
project := testAccCreateProject(t)
1618
resource.Test(t, resource.TestCase{
17-
PreCheck: func() { testAccPreCheck(t) },
1819
ProviderFactories: providerFactories,
1920
Steps: []resource.TestStep{
2021
{

internal/provider/data_source_gitlab_group_membership_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build acceptance
2+
// +build acceptance
3+
14
package provider
25

36
import (
@@ -12,7 +15,6 @@ func TestAccDataSourceGitlabMembership_basic(t *testing.T) {
1215
rInt := acctest.RandInt()
1316

1417
resource.Test(t, resource.TestCase{
15-
PreCheck: func() { testAccPreCheck(t) },
1618
ProviderFactories: providerFactories,
1719
Steps: []resource.TestStep{
1820
// Create the group and one member
@@ -45,16 +47,13 @@ func TestAccDataSourceGitlabMembership_basic(t *testing.T) {
4547
}
4648

4749
func TestAccDataSourceGitlabMembership_pagination(t *testing.T) {
48-
testAccCheck(t)
49-
5050
userCount := 21
5151

5252
group := testAccCreateGroups(t, 1)[0]
5353
users := testAccCreateUsers(t, userCount)
5454
testAccAddGroupMembers(t, group.ID, users)
5555

5656
resource.Test(t, resource.TestCase{
57-
PreCheck: func() { testAccPreCheck(t) },
5857
ProviderFactories: providerFactories,
5958
Steps: []resource.TestStep{
6059
{

internal/provider/data_source_gitlab_group_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build acceptance
2+
// +build acceptance
3+
14
package provider
25

36
import (
@@ -13,7 +16,6 @@ func TestAccDataSourceGitlabGroup_basic(t *testing.T) {
1316
rString := fmt.Sprintf("%s", acctest.RandString(5)) // nolint // TODO: Resolve this golangci-lint issue: S1025: the argument is already a string, there's no need to use fmt.Sprintf (gosimple)
1417

1518
resource.Test(t, resource.TestCase{
16-
PreCheck: func() { testAccPreCheck(t) },
1719
ProviderFactories: providerFactories,
1820
Steps: []resource.TestStep{
1921
// Get group using its ID

internal/provider/data_source_gitlab_group_variable_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build acceptance
2+
// +build acceptance
3+
14
package provider
25

36
import (
@@ -9,12 +12,9 @@ import (
912
)
1013

1114
func TestAccDataSourceGitlabGroupVariable_basic(t *testing.T) {
12-
testAccCheck(t)
13-
1415
testGroup := testAccCreateGroups(t, 1)[0]
1516

1617
resource.Test(t, resource.TestCase{
17-
PreCheck: func() { testAccPreCheck(t) },
1818
ProviderFactories: providerFactories,
1919
Steps: []resource.TestStep{
2020
{

internal/provider/data_source_gitlab_group_variables_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//go:build acceptance
2+
// +build acceptance
3+
14
package provider
25

36
import (
@@ -9,16 +12,13 @@ import (
912
)
1013

1114
func TestAccDataSourceGitlabGroupVariables_basic(t *testing.T) {
12-
testAccCheck(t)
13-
1415
testGroup := testAccCreateGroups(t, 1)[0]
1516
testVariables := make([]*gitlab.GroupVariable, 0)
1617
for i := 0; i < 25; i++ {
1718
testVariables = append(testVariables, testAccCreateGroupVariable(t, testGroup.ID))
1819
}
1920

2021
resource.Test(t, resource.TestCase{
21-
PreCheck: func() { testAccPreCheck(t) },
2222
ProviderFactories: providerFactories,
2323
Steps: []resource.TestStep{
2424
{

0 commit comments

Comments
 (0)