Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ linters:
# - spancheck
# - staticcheck
# - testifylint
- tparallel
# - unconvert
# - unparam
# - unused
Expand Down
2 changes: 2 additions & 0 deletions cmd/repro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 3 additions & 1 deletion integration/multi_test.go
Original file line number Diff line number Diff line change
@@ -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")
}
Expand Down
2 changes: 2 additions & 0 deletions integration/workflow_registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
)

func TestStability(t *testing.T) {
t.Parallel()

temp := setupTestDir(t)

// Create a basic workflow file
Expand Down
6 changes: 6 additions & 0 deletions integration/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -281,6 +283,8 @@ func (c *cmdRunner) Run() error {
}

func TestSpecWorkflows(t *testing.T) {
t.Parallel()

tests := []struct {
name string
inputDocs []string
Expand Down Expand Up @@ -511,6 +515,8 @@ func TestSpecWorkflows(t *testing.T) {
}

func TestFallbackCodeSamplesWorkflow(t *testing.T) {
t.Parallel()

spec := `{
"openapi": "3.0.0",
"info": {
Expand Down
4 changes: 4 additions & 0 deletions internal/github/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
)

func TestSortErrors(t *testing.T) {
t.Parallel()

type args struct {
errs []error
}
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions internal/locks/locks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

Expand All @@ -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())

Expand Down Expand Up @@ -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())

Expand Down Expand Up @@ -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()
Expand All @@ -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)

Expand Down
4 changes: 4 additions & 0 deletions internal/markdown/markdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
)

func TestCreateMarkdownTable(t *testing.T) {
t.Parallel()

type args struct {
contents [][]string
}
Expand Down Expand Up @@ -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)
})
Expand Down
4 changes: 4 additions & 0 deletions internal/run/remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
)

func TestParseGitHubRepoURL(t *testing.T) {
t.Parallel()

tests := []struct {
name string
url string
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions internal/suggest/errorCodes/errorCodes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
)

func TestBuildErrorCodesOverlay(t *testing.T) {
t.Parallel()

type args struct {
name, in, out string
}
Expand All @@ -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)
Expand All @@ -49,6 +53,8 @@ func TestBuildErrorCodesOverlay(t *testing.T) {
}

func TestDiagnose(t *testing.T) {
t.Parallel()

type args struct {
name, schema string
expectedCount int
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions internal/utils/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
)

func TestSingleSlotQueue(t *testing.T) {
t.Parallel()

log := []int{}
var logMu sync.Mutex

Expand Down
8 changes: 8 additions & 0 deletions pkg/merge/merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
)

func Test_merge_determinism(t *testing.T) {
t.Parallel()

// test data not included
t.Skip()
absSchemas := [][]byte{}
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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))
Expand All @@ -797,6 +803,8 @@ externalDocs:
}

func Test_MergeByResolvingLocalReferences_WithFileRefs(t *testing.T) {
t.Parallel()

ctx := context.Background()

tempDir, err := os.MkdirTemp("", "merge-test-*")
Expand Down
18 changes: 18 additions & 0 deletions pkg/overlay/overlay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions pkg/transform/convertSwagger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
)

func TestConvertSwaggerYAML(t *testing.T) {
t.Parallel()

// Create a buffer to store the filtered spec
var buf bytes.Buffer

Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions pkg/transform/filterOperations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
)

func TestFilterOperations(t *testing.T) {
t.Parallel()

// Create a buffer to store the filtered spec
var buf bytes.Buffer

Expand Down
2 changes: 2 additions & 0 deletions pkg/transform/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions pkg/transform/normalize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
)

func TestNormalize(t *testing.T) {
t.Parallel()

// Create a buffer to store the normalized spec
var testInput bytes.Buffer
Expand Down Expand Up @@ -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
Expand Down
Loading