Skip to content

Commit 4f0bf0d

Browse files
committed
Make tests run in parallelC
1 parent 613d130 commit 4f0bf0d

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

tools/cli/internal/cli/split/split_test.go

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
)
2727

2828
func TestSuccessfulSplit_Run(t *testing.T) {
29+
t.Parallel()
2930
fs := afero.NewMemMapFs()
3031
opts := &Opts{
3132
basePath: "../../../test/data/base_spec.json",
@@ -34,12 +35,11 @@ func TestSuccessfulSplit_Run(t *testing.T) {
3435
env: "dev",
3536
}
3637

37-
if err := opts.Run(); err != nil {
38-
t.Fatalf("Run() unexpected error: %v", err)
39-
}
38+
require.NoError(t, opts.Run())
4039
}
4140

4241
func TestSplitPublicPreviewRun(t *testing.T) {
42+
t.Parallel()
4343
fs := afero.NewMemMapFs()
4444
opts := &Opts{
4545
basePath: "../../../test/data/base_spec_with_public_preview.json",
@@ -48,9 +48,7 @@ func TestSplitPublicPreviewRun(t *testing.T) {
4848
env: "dev",
4949
}
5050

51-
if err := opts.Run(); err != nil {
52-
t.Fatalf("Run() unexpected error: %v", err)
53-
}
51+
require.NoError(t, opts.Run())
5452

5553
info, err := loadRunResultOas(fs, "foas-preview.yaml")
5654
require.NoError(t, err)
@@ -61,6 +59,7 @@ func TestSplitPublicPreviewRun(t *testing.T) {
6159
}
6260

6361
func TestSplitPrivatePreviewRun(t *testing.T) {
62+
t.Parallel()
6463
fs := afero.NewMemMapFs()
6564
opts := &Opts{
6665
basePath: "../../../test/data/base_spec_with_private_preview.json",
@@ -69,9 +68,7 @@ func TestSplitPrivatePreviewRun(t *testing.T) {
6968
env: "dev",
7069
}
7170

72-
if err := opts.Run(); err != nil {
73-
t.Fatalf("Run() unexpected error: %v", err)
74-
}
71+
require.NoError(t, opts.Run())
7572

7673
info, err := loadRunResultOas(fs, "foas-private-preview-new-feature.yaml")
7774
require.NoError(t, err)
@@ -81,7 +78,8 @@ func TestSplitPrivatePreviewRun(t *testing.T) {
8178
require.Contains(t, info.Spec.Paths.Map(), "/api/atlas/v2/groups")
8279
}
8380

84-
func TestSplitMulitplePreviewsRun(t *testing.T) {
81+
func TestSplitMultiplePreviewsRun(t *testing.T) {
82+
t.Parallel()
8583
fs := afero.NewMemMapFs()
8684
opts := &Opts{
8785
basePath: "../../../test/data/base_spec_with_multiple_private_and_public_previews.json",
@@ -90,9 +88,7 @@ func TestSplitMulitplePreviewsRun(t *testing.T) {
9088
fs: fs,
9189
}
9290

93-
if err := opts.Run(); err != nil {
94-
t.Fatalf("Run() unexpected error: %v", err)
95-
}
91+
require.NoError(t, opts.Run())
9692

9793
// private preview feature 1
9894
info, err := loadRunResultOas(fs, "foas-private-preview-new-feature.yaml")
@@ -120,6 +116,7 @@ func TestSplitMulitplePreviewsRun(t *testing.T) {
120116
}
121117

122118
func TestInjectSha_Run(t *testing.T) {
119+
t.Parallel()
123120
fs := afero.NewMemMapFs()
124121
opts := &Opts{
125122
basePath: "../../../test/data/base_spec.json",
@@ -129,10 +126,7 @@ func TestInjectSha_Run(t *testing.T) {
129126
env: "dev",
130127
}
131128

132-
if err := opts.Run(); err != nil {
133-
t.Fatalf("Run() unexpected error: %v", err)
134-
}
135-
129+
require.NoError(t, opts.Run())
136130
result, err := loadRunResultOas(fs, "foas-2023-01-01.yaml")
137131
require.NoError(t, err)
138132
// check sha
@@ -158,7 +152,9 @@ func TestOpts_PreRunE(t *testing.T) {
158152
}
159153

160154
for _, tt := range testCases {
155+
tt := tt // capture range variable
161156
t.Run(tt.name, func(t *testing.T) {
157+
t.Parallel()
162158
o := &Opts{
163159
basePath: tt.basePath,
164160
format: "json",
@@ -169,6 +165,7 @@ func TestOpts_PreRunE(t *testing.T) {
169165
}
170166

171167
func TestInvalidFormat_PreRun(t *testing.T) {
168+
t.Parallel()
172169
opts := &Opts{
173170
outputPath: "foas.json",
174171
basePath: "base.json",
@@ -181,6 +178,7 @@ func TestInvalidFormat_PreRun(t *testing.T) {
181178
}
182179

183180
func TestInvalidPath_PreRun(t *testing.T) {
181+
t.Parallel()
184182
opts := &Opts{
185183
outputPath: "foas.html",
186184
basePath: "base.json",

0 commit comments

Comments
 (0)