Skip to content

Commit 59678e1

Browse files
chore: mark all CLI-related tests in Go with t.Parallel()
1 parent c0de07e commit 59678e1

7 files changed

Lines changed: 152 additions & 0 deletions

File tree

internal/apiform/form_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,12 @@ var tests = map[string]struct {
8585
}
8686

8787
func TestEncode(t *testing.T) {
88+
t.Parallel()
89+
8890
for name, test := range tests {
8991
t.Run(name, func(t *testing.T) {
92+
t.Parallel()
93+
9094
buf := bytes.NewBuffer(nil)
9195
writer := multipart.NewWriter(buf)
9296
writer.SetBoundary("xxx")

internal/apiquery/query_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
)
77

88
func TestEncode(t *testing.T) {
9+
t.Parallel()
10+
911
tests := map[string]struct {
1012
val any
1113
settings QuerySettings
@@ -114,6 +116,8 @@ func TestEncode(t *testing.T) {
114116

115117
for name, test := range tests {
116118
t.Run(name, func(t *testing.T) {
119+
t.Parallel()
120+
117121
query := map[string]any{"query": test.val}
118122
values, err := MarshalWithSettings(query, test.settings)
119123
if err != nil {

internal/autocomplete/autocomplete_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
)
99

1010
func TestGetCompletions_EmptyArgs(t *testing.T) {
11+
t.Parallel()
12+
1113
root := &cli.Command{
1214
Commands: []*cli.Command{
1315
{Name: "generate", Usage: "Generate SDK"},
@@ -26,6 +28,8 @@ func TestGetCompletions_EmptyArgs(t *testing.T) {
2628
}
2729

2830
func TestGetCompletions_SubcommandPrefix(t *testing.T) {
31+
t.Parallel()
32+
2933
root := &cli.Command{
3034
Commands: []*cli.Command{
3135
{Name: "generate", Usage: "Generate SDK"},
@@ -43,6 +47,8 @@ func TestGetCompletions_SubcommandPrefix(t *testing.T) {
4347
}
4448

4549
func TestGetCompletions_HiddenCommand(t *testing.T) {
50+
t.Parallel()
51+
4652
root := &cli.Command{
4753
Commands: []*cli.Command{
4854
{Name: "visible", Usage: "Visible command"},
@@ -57,6 +63,8 @@ func TestGetCompletions_HiddenCommand(t *testing.T) {
5763
}
5864

5965
func TestGetCompletions_NestedSubcommand(t *testing.T) {
66+
t.Parallel()
67+
6068
root := &cli.Command{
6169
Commands: []*cli.Command{
6270
{
@@ -79,6 +87,8 @@ func TestGetCompletions_NestedSubcommand(t *testing.T) {
7987
}
8088

8189
func TestGetCompletions_FlagCompletion(t *testing.T) {
90+
t.Parallel()
91+
8292
root := &cli.Command{
8393
Commands: []*cli.Command{
8494
{
@@ -102,6 +112,8 @@ func TestGetCompletions_FlagCompletion(t *testing.T) {
102112
}
103113

104114
func TestGetCompletions_ShortFlagCompletion(t *testing.T) {
115+
t.Parallel()
116+
105117
root := &cli.Command{
106118
Commands: []*cli.Command{
107119
{
@@ -123,6 +135,8 @@ func TestGetCompletions_ShortFlagCompletion(t *testing.T) {
123135
}
124136

125137
func TestGetCompletions_FileFlagBehavior(t *testing.T) {
138+
t.Parallel()
139+
126140
root := &cli.Command{
127141
Commands: []*cli.Command{
128142
{
@@ -142,6 +156,8 @@ func TestGetCompletions_FileFlagBehavior(t *testing.T) {
142156
}
143157

144158
func TestGetCompletions_NonBoolFlagValue(t *testing.T) {
159+
t.Parallel()
160+
145161
root := &cli.Command{
146162
Commands: []*cli.Command{
147163
{
@@ -161,6 +177,8 @@ func TestGetCompletions_NonBoolFlagValue(t *testing.T) {
161177
}
162178

163179
func TestGetCompletions_BoolFlagDoesNotBlockCompletion(t *testing.T) {
180+
t.Parallel()
181+
164182
root := &cli.Command{
165183
Commands: []*cli.Command{
166184
{
@@ -185,6 +203,8 @@ func TestGetCompletions_BoolFlagDoesNotBlockCompletion(t *testing.T) {
185203
}
186204

187205
func TestGetCompletions_ColonCommands_NoColonTyped(t *testing.T) {
206+
t.Parallel()
207+
188208
root := &cli.Command{
189209
Commands: []*cli.Command{
190210
{Name: "config:get", Usage: "Get config value"},
@@ -202,6 +222,8 @@ func TestGetCompletions_ColonCommands_NoColonTyped(t *testing.T) {
202222
}
203223

204224
func TestGetCompletions_ColonCommands_ColonTyped_Bash(t *testing.T) {
225+
t.Parallel()
226+
205227
root := &cli.Command{
206228
Commands: []*cli.Command{
207229
{Name: "config:get", Usage: "Get config value"},
@@ -221,6 +243,8 @@ func TestGetCompletions_ColonCommands_ColonTyped_Bash(t *testing.T) {
221243
}
222244

223245
func TestGetCompletions_ColonCommands_ColonTyped_Zsh(t *testing.T) {
246+
t.Parallel()
247+
224248
root := &cli.Command{
225249
Commands: []*cli.Command{
226250
{Name: "config:get", Usage: "Get config value"},
@@ -240,6 +264,8 @@ func TestGetCompletions_ColonCommands_ColonTyped_Zsh(t *testing.T) {
240264
}
241265

242266
func TestGetCompletions_BashStyleColonCompletion(t *testing.T) {
267+
t.Parallel()
268+
243269
root := &cli.Command{
244270
Commands: []*cli.Command{
245271
{Name: "config:get", Usage: "Get config value"},
@@ -257,6 +283,8 @@ func TestGetCompletions_BashStyleColonCompletion(t *testing.T) {
257283
}
258284

259285
func TestGetCompletions_BashStyleColonCompletion_NoMatch(t *testing.T) {
286+
t.Parallel()
287+
260288
root := &cli.Command{
261289
Commands: []*cli.Command{
262290
{Name: "config:get", Usage: "Get config value"},
@@ -271,6 +299,8 @@ func TestGetCompletions_BashStyleColonCompletion_NoMatch(t *testing.T) {
271299
}
272300

273301
func TestGetCompletions_ZshStyleColonCompletion(t *testing.T) {
302+
t.Parallel()
303+
274304
root := &cli.Command{
275305
Commands: []*cli.Command{
276306
{Name: "config:get", Usage: "Get config value"},
@@ -287,6 +317,8 @@ func TestGetCompletions_ZshStyleColonCompletion(t *testing.T) {
287317
}
288318

289319
func TestGetCompletions_MixedColonAndRegularCommands(t *testing.T) {
320+
t.Parallel()
321+
290322
root := &cli.Command{
291323
Commands: []*cli.Command{
292324
{Name: "generate", Usage: "Generate SDK"},
@@ -305,6 +337,8 @@ func TestGetCompletions_MixedColonAndRegularCommands(t *testing.T) {
305337
}
306338

307339
func TestGetCompletions_FlagWithBoolFlagSkipsValue(t *testing.T) {
340+
t.Parallel()
341+
308342
root := &cli.Command{
309343
Commands: []*cli.Command{
310344
{
@@ -329,6 +363,8 @@ func TestGetCompletions_FlagWithBoolFlagSkipsValue(t *testing.T) {
329363
}
330364

331365
func TestGetCompletions_MultipleFlagsBeforeSubcommand(t *testing.T) {
366+
t.Parallel()
367+
332368
root := &cli.Command{
333369
Commands: []*cli.Command{
334370
{
@@ -353,6 +389,8 @@ func TestGetCompletions_MultipleFlagsBeforeSubcommand(t *testing.T) {
353389
}
354390

355391
func TestGetCompletions_CommandAliases(t *testing.T) {
392+
t.Parallel()
393+
356394
root := &cli.Command{
357395
Commands: []*cli.Command{
358396
{Name: "generate", Aliases: []string{"gen", "g"}, Usage: "Generate SDK"},
@@ -372,6 +410,8 @@ func TestGetCompletions_CommandAliases(t *testing.T) {
372410
}
373411

374412
func TestGetCompletions_AllFlagsWhenNoPrefix(t *testing.T) {
413+
t.Parallel()
414+
375415
root := &cli.Command{
376416
Commands: []*cli.Command{
377417
{

internal/jsonview/explorer_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
)
1111

1212
func TestNavigateForward_EmptyRowData(t *testing.T) {
13+
t.Parallel()
14+
1315
// An empty JSON array produces a TableView with no rows.
1416
emptyArray := gjson.Parse("[]")
1517
view, err := newTableView("", emptyArray, false)
@@ -38,6 +40,8 @@ type rawJSONItem struct {
3840
func (r rawJSONItem) RawJSON() string { return r.raw }
3941

4042
func TestMarshalItemsToJSONArray_WithHasRawJSON(t *testing.T) {
43+
t.Parallel()
44+
4145
items := []any{
4246
rawJSONItem{raw: `{"id":1,"name":"alice"}`},
4347
rawJSONItem{raw: `{"id":2,"name":"bob"}`},
@@ -49,6 +53,8 @@ func TestMarshalItemsToJSONArray_WithHasRawJSON(t *testing.T) {
4953
}
5054

5155
func TestMarshalItemsToJSONArray_WithoutHasRawJSON(t *testing.T) {
56+
t.Parallel()
57+
5258
items := []any{
5359
map[string]any{"id": 1, "name": "alice"},
5460
map[string]any{"id": 2, "name": "bob"},

internal/requestflag/innerflag_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
)
99

1010
func TestInnerFlagSet(t *testing.T) {
11+
t.Parallel()
12+
1113
tests := []struct {
1214
name string
1315
flagType string
@@ -27,6 +29,8 @@ func TestInnerFlagSet(t *testing.T) {
2729

2830
for _, tt := range tests {
2931
t.Run(tt.name, func(t *testing.T) {
32+
t.Parallel()
33+
3034
outerFlag := &Flag[map[string]any]{
3135
Name: "test-flag",
3236
}
@@ -81,6 +85,8 @@ func TestInnerFlagSet(t *testing.T) {
8185
}
8286

8387
func TestInnerFlagValidator(t *testing.T) {
88+
t.Parallel()
89+
8490
outerFlag := &Flag[map[string]any]{Name: "test-flag"}
8591

8692
innerFlag := &InnerFlag[int64]{
@@ -105,6 +111,8 @@ func TestInnerFlagValidator(t *testing.T) {
105111
}
106112

107113
func TestWithInnerFlags(t *testing.T) {
114+
t.Parallel()
115+
108116
outerFlag := &Flag[map[string]any]{Name: "outer"}
109117
innerFlag := &InnerFlag[string]{
110118
Name: "outer.baz",
@@ -126,6 +134,8 @@ func TestWithInnerFlags(t *testing.T) {
126134
}
127135

128136
func TestInnerFlagTypeNames(t *testing.T) {
137+
t.Parallel()
138+
129139
tests := []struct {
130140
name string
131141
flag cli.DocGenerationFlag
@@ -143,15 +153,21 @@ func TestInnerFlagTypeNames(t *testing.T) {
143153

144154
for _, tt := range tests {
145155
t.Run(tt.name, func(t *testing.T) {
156+
t.Parallel()
157+
146158
typeName := tt.flag.TypeName()
147159
assert.Equal(t, tt.expected, typeName, "Expected type name %q, got %q", tt.expected, typeName)
148160
})
149161
}
150162
}
151163

152164
func TestInnerYamlHandling(t *testing.T) {
165+
t.Parallel()
166+
153167
// Test with map value
154168
t.Run("Parse YAML to map", func(t *testing.T) {
169+
t.Parallel()
170+
155171
outerFlag := &Flag[map[string]any]{Name: "outer"}
156172
innerFlag := &InnerFlag[map[string]any]{
157173
Name: "outer.baz",
@@ -176,6 +192,8 @@ func TestInnerYamlHandling(t *testing.T) {
176192

177193
// Test with invalid YAML
178194
t.Run("Parse invalid YAML", func(t *testing.T) {
195+
t.Parallel()
196+
179197
outerFlag := &Flag[map[string]any]{Name: "outer"}
180198
innerFlag := &InnerFlag[map[string]any]{
181199
Name: "outer.baz",
@@ -190,6 +208,8 @@ func TestInnerYamlHandling(t *testing.T) {
190208

191209
// Test setting inner flags on a map multiple times
192210
t.Run("Set inner flags on map multiple times", func(t *testing.T) {
211+
t.Parallel()
212+
193213
outerFlag := &Flag[map[string]any]{Name: "outer"}
194214

195215
// Set first inner flag
@@ -219,6 +239,8 @@ func TestInnerYamlHandling(t *testing.T) {
219239

220240
// Test setting YAML and then an inner flag
221241
t.Run("Set YAML and then inner flag", func(t *testing.T) {
242+
t.Parallel()
243+
222244
outerFlag := &Flag[map[string]any]{Name: "outer"}
223245

224246
// First set the outer flag with YAML
@@ -246,7 +268,11 @@ func TestInnerYamlHandling(t *testing.T) {
246268
}
247269

248270
func TestInnerFlagWithSliceType(t *testing.T) {
271+
t.Parallel()
272+
249273
t.Run("Setting inner flags on slice of maps", func(t *testing.T) {
274+
t.Parallel()
275+
250276
outerFlag := &Flag[[]map[string]any]{Name: "outer"}
251277

252278
// Set first inner flag (should create first item)
@@ -284,6 +310,8 @@ func TestInnerFlagWithSliceType(t *testing.T) {
284310
})
285311

286312
t.Run("Appending to existing slice", func(t *testing.T) {
313+
t.Parallel()
314+
287315
// Initialize with existing items
288316
outerFlag := &Flag[[]map[string]any]{Name: "outer"}
289317
err := outerFlag.Set(outerFlag.Name, `{name: initial}`)

0 commit comments

Comments
 (0)