Skip to content

Commit aa3dbcd

Browse files
authored
chore: add t.Parallel() to speed up tests (#184)
This makes the test suite run in under a minute, compared to several minutes per run before.
1 parent c440681 commit aa3dbcd

17 files changed

+36
-7
lines changed

.golangci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,16 @@ linters:
1818
- makezero
1919
- misspell
2020
- nilerr
21+
- paralleltest
2122
- predeclared
2223
- staticcheck
2324
- unconvert
2425
- unparam
2526
- unused
2627
- usetesting
28+
29+
linters-settings:
30+
paralleltest:
31+
# Terraform acceptance subtests all share a Coder instance, and cannot run
32+
# in parallel.
33+
ignore-missing-subtests: true

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ fmt:
44
go fmt ./...
55
terraform fmt -recursive
66

7-
vet:
8-
go vet ./...
7+
lint:
8+
golangci-lint run ./...
99

1010
gen:
1111
go generate ./...

integration/integration_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
// - Runs the `main.tf` specified in the given test directory against the Coder deployment
2323
// - Asserts the state of the deployment via `codersdk`.
2424
func TestIntegration(t *testing.T) {
25+
t.Parallel()
2526
if os.Getenv("TF_ACC") == "1" {
2627
t.Skip("Skipping integration tests during tf acceptance tests")
2728
}
@@ -145,6 +146,8 @@ func TestIntegration(t *testing.T) {
145146
},
146147
} {
147148
t.Run(tt.name, func(t *testing.T) {
149+
t.Parallel()
150+
148151
client := StartCoder(ctx, t, tt.name, true)
149152
wd, err := os.Getwd()
150153
require.NoError(t, err)

internal/provider/group_data_source_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
)
1717

1818
func TestAccGroupDataSource(t *testing.T) {
19+
t.Parallel()
1920
if os.Getenv("TF_ACC") == "" {
2021
t.Skip("Acceptance tests are disabled.")
2122
}

internal/provider/group_resource_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
)
1717

1818
func TestAccGroupResource(t *testing.T) {
19+
t.Parallel()
1920
if os.Getenv("TF_ACC") == "" {
2021
t.Skip("Acceptance tests are disabled.")
2122
}
@@ -133,6 +134,7 @@ func TestAccGroupResource(t *testing.T) {
133134
}
134135

135136
func TestAccGroupResourceAGPL(t *testing.T) {
137+
t.Parallel()
136138
if os.Getenv("TF_ACC") == "" {
137139
t.Skip("Acceptance tests are disabled.")
138140
}

internal/provider/license_resource_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
)
1414

1515
func TestAccLicenseResource(t *testing.T) {
16+
t.Parallel()
1617
if os.Getenv("TF_ACC") == "" {
1718
t.Skip("Acceptance tests are disabled.")
1819
}

internal/provider/organization_data_source_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
)
1717

1818
func TestAccOrganizationDataSource(t *testing.T) {
19+
t.Parallel()
1920
if os.Getenv("TF_ACC") == "" {
2021
t.Skip("Acceptance tests are disabled.")
2122
}

internal/provider/organization_resource_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
)
2020

2121
func TestAccOrganizationResource(t *testing.T) {
22+
t.Parallel()
2223
if os.Getenv("TF_ACC") == "" {
2324
t.Skip("Acceptance tests are disabled.")
2425
}

internal/provider/organization_sync_settings_resource_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
)
1919

2020
func TestAccOrganizationSyncSettingsResource(t *testing.T) {
21+
t.Parallel()
2122
if os.Getenv("TF_ACC") == "" {
2223
t.Skip("Acceptance tests are disabled.")
2324
}

internal/provider/provider_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var testAccProtoV6ProviderFactories = map[string]func() (tfprotov6.ProviderServe
1616
}
1717

1818
func testAccPreCheck(t *testing.T) {
19+
t.Helper()
1920
// You can add code here to run prior to any test case execution, for example assertions
2021
// about the appropriate environment variables being set are common to see in a pre-check
2122
// function.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy