diff --git a/.golangci.yml b/.golangci.yml index 98eed9e..7efde44 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -18,9 +18,16 @@ linters: - makezero - misspell - nilerr + - paralleltest - predeclared - staticcheck - unconvert - unparam - unused - usetesting + +linters-settings: + paralleltest: + # Terraform acceptance subtests all share a Coder instance, and cannot run + # in parallel. + ignore-missing-subtests: true diff --git a/Makefile b/Makefile index e26660e..faf8f49 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,8 @@ fmt: go fmt ./... terraform fmt -recursive -vet: - go vet ./... +lint: + golangci-lint run ./... gen: go generate ./... diff --git a/integration/integration_test.go b/integration/integration_test.go index aeb90a5..2ed60eb 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -22,6 +22,7 @@ import ( // - Runs the `main.tf` specified in the given test directory against the Coder deployment // - Asserts the state of the deployment via `codersdk`. func TestIntegration(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "1" { t.Skip("Skipping integration tests during tf acceptance tests") } @@ -145,6 +146,8 @@ func TestIntegration(t *testing.T) { }, } { t.Run(tt.name, func(t *testing.T) { + t.Parallel() + client := StartCoder(ctx, t, tt.name, true) wd, err := os.Getwd() require.NoError(t, err) diff --git a/internal/provider/group_data_source_test.go b/internal/provider/group_data_source_test.go index 5a081af..6581343 100644 --- a/internal/provider/group_data_source_test.go +++ b/internal/provider/group_data_source_test.go @@ -16,6 +16,7 @@ import ( ) func TestAccGroupDataSource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/group_resource_test.go b/internal/provider/group_resource_test.go index 865851a..090e504 100644 --- a/internal/provider/group_resource_test.go +++ b/internal/provider/group_resource_test.go @@ -16,6 +16,7 @@ import ( ) func TestAccGroupResource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } @@ -133,6 +134,7 @@ func TestAccGroupResource(t *testing.T) { } func TestAccGroupResourceAGPL(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/license_resource_test.go b/internal/provider/license_resource_test.go index 9a4abc7..fe124cd 100644 --- a/internal/provider/license_resource_test.go +++ b/internal/provider/license_resource_test.go @@ -13,6 +13,7 @@ import ( ) func TestAccLicenseResource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/organization_data_source_test.go b/internal/provider/organization_data_source_test.go index c7bb982..9eb9c86 100644 --- a/internal/provider/organization_data_source_test.go +++ b/internal/provider/organization_data_source_test.go @@ -16,6 +16,7 @@ import ( ) func TestAccOrganizationDataSource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/organization_resource_test.go b/internal/provider/organization_resource_test.go index 40a7465..6f027e2 100644 --- a/internal/provider/organization_resource_test.go +++ b/internal/provider/organization_resource_test.go @@ -19,6 +19,7 @@ import ( ) func TestAccOrganizationResource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/organization_sync_settings_resource_test.go b/internal/provider/organization_sync_settings_resource_test.go index 66f7b81..0d55b71 100644 --- a/internal/provider/organization_sync_settings_resource_test.go +++ b/internal/provider/organization_sync_settings_resource_test.go @@ -18,6 +18,7 @@ import ( ) func TestAccOrganizationSyncSettingsResource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go index 2f8b921..7dab7ff 100644 --- a/internal/provider/provider_test.go +++ b/internal/provider/provider_test.go @@ -16,6 +16,7 @@ var testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServe } func testAccPreCheck(t *testing.T) { + t.Helper() // You can add code here to run prior to any test case execution, for example assertions // about the appropriate environment variables being set are common to see in a pre-check // function. diff --git a/internal/provider/provisioner_key_resource_test.go b/internal/provider/provisioner_key_resource_test.go index 9c89647..7b05568 100644 --- a/internal/provider/provisioner_key_resource_test.go +++ b/internal/provider/provisioner_key_resource_test.go @@ -18,6 +18,7 @@ import ( ) func TestAccProvisionerKeyResource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/template_data_source_test.go b/internal/provider/template_data_source_test.go index f6759b3..564e12f 100644 --- a/internal/provider/template_data_source_test.go +++ b/internal/provider/template_data_source_test.go @@ -20,6 +20,7 @@ import ( ) func TestAccTemplateDataSource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/template_resource_test.go b/internal/provider/template_resource_test.go index 5bb1e3b..0cc0015 100644 --- a/internal/provider/template_resource_test.go +++ b/internal/provider/template_resource_test.go @@ -23,6 +23,7 @@ import ( ) func TestAccTemplateResource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } @@ -637,6 +638,7 @@ func TestAccTemplateResource(t *testing.T) { } func TestAccTemplateResourceEnterprise(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } @@ -782,6 +784,7 @@ func TestAccTemplateResourceEnterprise(t *testing.T) { } func TestAccTemplateResourceAGPL(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } @@ -875,6 +878,7 @@ func TestAccTemplateResourceAGPL(t *testing.T) { } func TestAccTemplateResourceVariables(t *testing.T) { + t.Parallel() cfg := ` provider coderd { url = %q @@ -1137,6 +1141,7 @@ func testAccCheckNumTemplateVersions(ctx context.Context, client *codersdk.Clien } func TestReconcileVersionIDs(t *testing.T) { + t.Parallel() aUUID := uuid.New() bUUID := uuid.New() cases := []struct { @@ -1507,6 +1512,8 @@ func TestReconcileVersionIDs(t *testing.T) { for _, c := range cases { c := c t.Run(c.Name, func(t *testing.T) { + t.Parallel() + diag := c.planVersions.reconcileVersionIDs(c.inputState, c.configVersions, c.cfgHasActiveVersion) if c.expectError { require.True(t, diag.HasError()) diff --git a/internal/provider/user_data_source_test.go b/internal/provider/user_data_source_test.go index 6a9309f..695ae27 100644 --- a/internal/provider/user_data_source_test.go +++ b/internal/provider/user_data_source_test.go @@ -16,6 +16,7 @@ import ( ) func TestAccUserDataSource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/user_resource_test.go b/internal/provider/user_resource_test.go index b9c6bb7..dd515d9 100644 --- a/internal/provider/user_resource_test.go +++ b/internal/provider/user_resource_test.go @@ -14,6 +14,7 @@ import ( ) func TestAccUserResource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } diff --git a/internal/provider/uuid_internal_test.go b/internal/provider/uuid_internal_test.go index 697d9c3..ff9fd32 100644 --- a/internal/provider/uuid_internal_test.go +++ b/internal/provider/uuid_internal_test.go @@ -51,11 +51,10 @@ func TestUUIDTypeValueFromTerraform(t *testing.T) { test := test t.Run(test.name, func(t *testing.T) { t.Parallel() - ctx := context.Background() + ctx := context.Background() actual, err := uuidType.ValueFromTerraform(UUIDType, ctx, test.input) require.NoError(t, err) - require.Equal(t, test.expected, actual) }) } @@ -86,10 +85,9 @@ func TestUUIDToStringValue(t *testing.T) { name, test := name, test t.Run(name, func(t *testing.T) { t.Parallel() - ctx := context.Background() + ctx := context.Background() s, _ := test.uuid.ToStringValue(ctx) - require.Equal(t, test.expected, s) }) } diff --git a/internal/provider/workspace_proxy_resource_test.go b/internal/provider/workspace_proxy_resource_test.go index 88d7013..9626e83 100644 --- a/internal/provider/workspace_proxy_resource_test.go +++ b/internal/provider/workspace_proxy_resource_test.go @@ -15,6 +15,7 @@ import ( ) func TestAccWorkspaceProxyResource(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } @@ -56,11 +57,12 @@ func TestAccWorkspaceProxyResource(t *testing.T) { } func TestAccWorkspaceProxyResourceAGPL(t *testing.T) { + t.Parallel() if os.Getenv("TF_ACC") == "" { t.Skip("Acceptance tests are disabled.") } ctx := context.Background() - client := integration.StartCoder(ctx, t, "ws_proxy_acc", false) + client := integration.StartCoder(ctx, t, "ws_proxy_acc_agpl", false) cfg1 := testAccWorkspaceProxyResourceConfig{ URL: client.URL.String(),