diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index e9095ae94..9c3800601 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -91,6 +91,6 @@ jobs: - name: Build run: go build ./... - - run: go test -json -v -p 1 -timeout=20m ./... | gotestfmt + - run: go test -json -v -timeout=20m ./... | gotestfmt env: SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }} diff --git a/.golangci.yml b/.golangci.yml index f3628a7c7..6030a721b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -28,6 +28,7 @@ linters: # - spancheck # - staticcheck # - testifylint + - tparallel # - unconvert # - unparam # - unused diff --git a/cmd/repro_test.go b/cmd/repro_test.go index 016afe22c..6cc4e9805 100644 --- a/cmd/repro_test.go +++ b/cmd/repro_test.go @@ -31,6 +31,8 @@ func getSpeakeasyBinary() string { } func TestReproEndToEnd(t *testing.T) { + t.Parallel() + // For now skip on windows - building the temp binary is not working on windows if runtime.GOOS == "windows" { t.Skip("Skipping repro test on Windows") diff --git a/integration/multi_test.go b/integration/multi_test.go index a6ef8bc53..8805642ad 100644 --- a/integration/multi_test.go +++ b/integration/multi_test.go @@ -1,17 +1,19 @@ package integration_tests import ( - "github.com/google/go-cmp/cmp" "os" "path/filepath" "runtime" "testing" + "github.com/google/go-cmp/cmp" "github.com/speakeasy-api/sdk-gen-config/workflow" "github.com/stretchr/testify/require" ) func TestMultiFileStability(t *testing.T) { + t.Parallel() + if runtime.GOOS == "windows" { t.Skip("Skipping test on Windows") } diff --git a/integration/workflow_registry_test.go b/integration/workflow_registry_test.go index 0321772f6..0fdd5e9da 100644 --- a/integration/workflow_registry_test.go +++ b/integration/workflow_registry_test.go @@ -11,6 +11,8 @@ import ( ) func TestStability(t *testing.T) { + t.Parallel() + temp := setupTestDir(t) // Create a basic workflow file diff --git a/integration/workflow_test.go b/integration/workflow_test.go index 124e16d80..28e841de3 100644 --- a/integration/workflow_test.go +++ b/integration/workflow_test.go @@ -27,6 +27,8 @@ import ( // If all test groups are run at the same time you will see test failures. func TestWorkflowWithEnvVar(t *testing.T) { + t.Parallel() + temp := setupTestDir(t) // Create workflow file and associated resources @@ -281,6 +283,8 @@ func (c *cmdRunner) Run() error { } func TestSpecWorkflows(t *testing.T) { + t.Parallel() + tests := []struct { name string inputDocs []string @@ -511,6 +515,8 @@ func TestSpecWorkflows(t *testing.T) { } func TestFallbackCodeSamplesWorkflow(t *testing.T) { + t.Parallel() + spec := `{ "openapi": "3.0.0", "info": { diff --git a/internal/github/github_test.go b/internal/github/github_test.go index 4b9e163fe..b1ffa1914 100644 --- a/internal/github/github_test.go +++ b/internal/github/github_test.go @@ -10,6 +10,8 @@ import ( ) func TestSortErrors(t *testing.T) { + t.Parallel() + type args struct { errs []error } @@ -68,6 +70,8 @@ func TestSortErrors(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() + github.SortErrors(tt.args.errs) assert.Equal(t, tt.want, tt.args.errs) diff --git a/internal/locks/locks_test.go b/internal/locks/locks_test.go index 765565a8f..7f2634dff 100644 --- a/internal/locks/locks_test.go +++ b/internal/locks/locks_test.go @@ -13,6 +13,8 @@ import ( ) func TestCLIUpdateMutex_TryLock(t *testing.T) { + t.Parallel() + // Create a custom lock file name to avoid conflicts with real CLI operations testLockName := fmt.Sprintf("speakeasy-test-%d.lock", time.Now().UnixNano()) @@ -39,6 +41,8 @@ func TestCLIUpdateMutex_TryLock(t *testing.T) { } func TestCLIUpdateMutex_Contention(t *testing.T) { + t.Parallel() + // Create a custom lock file name to avoid conflicts with real CLI operations testLockName := fmt.Sprintf("speakeasy-test-contention-%d.lock", time.Now().UnixNano()) @@ -98,6 +102,8 @@ func TestCLIUpdateMutex_Contention(t *testing.T) { } func TestCLIUpdateMutex_Unlock(t *testing.T) { + t.Parallel() + // Create a custom lock file name to avoid conflicts with real CLI operations testLockName := fmt.Sprintf("speakeasy-test-%d.lock", time.Now().UnixNano()) @@ -132,6 +138,8 @@ func TestCLIUpdateMutex_Unlock(t *testing.T) { } func TestCLIUpdateMutex_Singleton(t *testing.T) { + t.Parallel() + // Test that the singleton functions return the same instance mutex1 := CLIUpdateLock() mutex2 := CLIUpdateLock() @@ -141,6 +149,8 @@ func TestCLIUpdateMutex_Singleton(t *testing.T) { } func TestCLIUpdateMutex_ConcurrentUsers(t *testing.T) { + t.Parallel() + testLockName := "concurrent-test.lock" lockPath := filepath.Join(os.TempDir(), testLockName) diff --git a/internal/markdown/markdown_test.go b/internal/markdown/markdown_test.go index be432c2bd..4f86a6034 100644 --- a/internal/markdown/markdown_test.go +++ b/internal/markdown/markdown_test.go @@ -9,6 +9,8 @@ import ( ) func TestCreateMarkdownTable(t *testing.T) { + t.Parallel() + type args struct { contents [][]string } @@ -104,6 +106,8 @@ func TestCreateMarkdownTable(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() + got := markdown.CreateMarkdownTable(tt.args.contents) assert.Equal(t, strings.TrimPrefix(tt.want, "\n"), got) }) diff --git a/internal/run/remote_test.go b/internal/run/remote_test.go index f0b67fa93..0684a8e2b 100644 --- a/internal/run/remote_test.go +++ b/internal/run/remote_test.go @@ -5,6 +5,8 @@ import ( ) func TestParseGitHubRepoURL(t *testing.T) { + t.Parallel() + tests := []struct { name string url string @@ -54,6 +56,8 @@ func TestParseGitHubRepoURL(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() + gotOrg, gotRepo, err := parseGitHubRepoURL(tt.url) if (err != nil) != tt.wantErr { t.Errorf("parseGitHubRepoURL() error = %v, wantErr %v", err, tt.wantErr) diff --git a/internal/suggest/errorCodes/errorCodes_test.go b/internal/suggest/errorCodes/errorCodes_test.go index 34263d7d7..d2da81c79 100644 --- a/internal/suggest/errorCodes/errorCodes_test.go +++ b/internal/suggest/errorCodes/errorCodes_test.go @@ -12,6 +12,8 @@ import ( ) func TestBuildErrorCodesOverlay(t *testing.T) { + t.Parallel() + type args struct { name, in, out string } @@ -24,6 +26,8 @@ func TestBuildErrorCodesOverlay(t *testing.T) { for _, tt := range toTest { t.Run(tt.name, func(t *testing.T) { + t.Parallel() + ctx := context.Background() overlay, err := errorCodes.BuildErrorCodesOverlay(ctx, tt.in) @@ -49,6 +53,8 @@ func TestBuildErrorCodesOverlay(t *testing.T) { } func TestDiagnose(t *testing.T) { + t.Parallel() + type args struct { name, schema string expectedCount int @@ -60,6 +66,8 @@ func TestDiagnose(t *testing.T) { for _, tt := range toTest { t.Run(tt.name, func(t *testing.T) { + t.Parallel() + ctx := context.Background() _, _, model, err := schemas.LoadDocument(ctx, tt.schema) require.NoError(t, err) diff --git a/internal/utils/utils_test.go b/internal/utils/utils_test.go index 739ef2934..46afd05f3 100644 --- a/internal/utils/utils_test.go +++ b/internal/utils/utils_test.go @@ -10,6 +10,8 @@ import ( ) func TestSingleSlotQueue(t *testing.T) { + t.Parallel() + log := []int{} var logMu sync.Mutex diff --git a/pkg/merge/merge_test.go b/pkg/merge/merge_test.go index b7626c954..f513a8894 100644 --- a/pkg/merge/merge_test.go +++ b/pkg/merge/merge_test.go @@ -15,6 +15,8 @@ import ( ) func Test_merge_determinism(t *testing.T) { + t.Parallel() + // test data not included t.Skip() absSchemas := [][]byte{} @@ -54,6 +56,8 @@ func Test_merge_determinism(t *testing.T) { } func Test_merge_Success(t *testing.T) { + t.Parallel() + type args struct { inSchemas [][]byte } @@ -789,6 +793,8 @@ externalDocs: } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() + got, _ := merge(tt.args.inSchemas, !tt.jsonOut) assert.Equal(t, tt.want, string(got)) @@ -797,6 +803,8 @@ externalDocs: } func Test_MergeByResolvingLocalReferences_WithFileRefs(t *testing.T) { + t.Parallel() + ctx := context.Background() tempDir, err := os.MkdirTemp("", "merge-test-*") diff --git a/pkg/overlay/overlay_test.go b/pkg/overlay/overlay_test.go index 7d0ae6af6..6da8a4d6d 100644 --- a/pkg/overlay/overlay_test.go +++ b/pkg/overlay/overlay_test.go @@ -21,38 +21,56 @@ const ( ) func TestApply_inYAML_outYAML(t *testing.T) { + t.Parallel() + test(t, schemaFile, overlayFileV1, expectedFile, true) } func TestApply_inJSON_outJSON(t *testing.T) { + t.Parallel() + test(t, schemaJSON, overlayFileV1, expectedFileJSON, false) } func TestApply_inYAML_outJSON(t *testing.T) { + t.Parallel() + test(t, schemaFile, overlayFileV1, expectedFileJSON, false) } func TestApply_inJSON_outYAML(t *testing.T) { + t.Parallel() + test(t, schemaJSON, overlayFileV1, expectedFileYAMLFromJSON, true) } func TestApply_inYAML_outYAML_v2(t *testing.T) { + t.Parallel() + test(t, schemaFile, overlayFileV2, expectedFile, true) } func TestApply_inJSON_outJSON_v2(t *testing.T) { + t.Parallel() + test(t, schemaJSON, overlayFileV2, expectedFileJSON, false) } func TestApply_inYAML_outJSON_v2(t *testing.T) { + t.Parallel() + test(t, schemaFile, overlayFileV2, expectedFileJSON, false) } func TestApply_inJSON_outYAML_v2(t *testing.T) { + t.Parallel() + test(t, schemaJSON, overlayFileV2, expectedFileYAMLFromJSON, true) } func TestApply_StrictFailure(t *testing.T) { + t.Parallel() + tmpFile, err := os.CreateTemp("", "output.yaml") require.NoError(t, err) _, err = Apply(schemaFile, overlayStrictFailure, true, tmpFile, true, true) diff --git a/pkg/transform/convertSwagger_test.go b/pkg/transform/convertSwagger_test.go index 79de00c87..85fde16f3 100644 --- a/pkg/transform/convertSwagger_test.go +++ b/pkg/transform/convertSwagger_test.go @@ -11,6 +11,8 @@ import ( ) func TestConvertSwaggerYAML(t *testing.T) { + t.Parallel() + // Create a buffer to store the filtered spec var buf bytes.Buffer @@ -39,6 +41,8 @@ func TestConvertSwaggerYAML(t *testing.T) { } func TestConvertSwaggerJSON(t *testing.T) { + t.Parallel() + // Create a buffer to store the filtered spec var buf bytes.Buffer diff --git a/pkg/transform/filterOperations_test.go b/pkg/transform/filterOperations_test.go index be2e0d36e..142c431df 100644 --- a/pkg/transform/filterOperations_test.go +++ b/pkg/transform/filterOperations_test.go @@ -11,6 +11,8 @@ import ( ) func TestFilterOperations(t *testing.T) { + t.Parallel() + // Create a buffer to store the filtered spec var buf bytes.Buffer diff --git a/pkg/transform/format_test.go b/pkg/transform/format_test.go index 16d577930..b050a33ac 100644 --- a/pkg/transform/format_test.go +++ b/pkg/transform/format_test.go @@ -13,6 +13,8 @@ import ( ) func TestFormat(t *testing.T) { + t.Parallel() + // Create a buffer to store the formatted spec var testInput bytes.Buffer var testOutput bytes.Buffer diff --git a/pkg/transform/normalize_test.go b/pkg/transform/normalize_test.go index 7c876e532..5934b0581 100644 --- a/pkg/transform/normalize_test.go +++ b/pkg/transform/normalize_test.go @@ -13,6 +13,7 @@ import ( ) func TestNormalize(t *testing.T) { + t.Parallel() // Create a buffer to store the normalized spec var testInput bytes.Buffer @@ -54,6 +55,7 @@ func TestNormalize(t *testing.T) { } func TestNormalizeNoPrefixItems(t *testing.T) { + t.Parallel() // Create a buffer to store the normalized spec var testInput bytes.Buffer