Skip to content

Commit cf5ebe9

Browse files
test: add t.Parallel() to safe codemod tests
Adds t.Parallel() to TestGetPermissionsReadCodemod and related permissions codemod tests, plus TestMCPModeToTypeCodemod and its subtests. Each test constructs its own local Codemod instance (a plain struct with pure function fields) and only touches local content/frontmatter variables — no shared mutable state, env vars, working directory changes, fixed ports/paths, or external services. Validated with go test -race on the affected tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 21b4067 commit cf5ebe9

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

pkg/cli/codemod_mcp_mode_to_type_test.go

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

1212
func TestMCPModeToTypeCodemod(t *testing.T) {
13+
t.Parallel()
1314
codemod := getMCPModeToTypeCodemod()
1415

1516
t.Run("renames mode to type in custom MCP servers", func(t *testing.T) {
17+
t.Parallel()
1618
content := `---
1719
engine: copilot
1820
tools:
@@ -49,6 +51,7 @@ mcp-servers:
4951
})
5052

5153
t.Run("does not modify workflows without mcp-servers", func(t *testing.T) {
54+
t.Parallel()
5255
content := `---
5356
engine: copilot
5457
tools:
@@ -75,6 +78,7 @@ tools:
7578
})
7679

7780
t.Run("does not modify GitHub tool mode field", func(t *testing.T) {
81+
t.Parallel()
7882
content := `---
7983
engine: copilot
8084
tools:
@@ -113,6 +117,7 @@ mcp-servers:
113117
})
114118

115119
t.Run("handles multiple MCP servers with mode", func(t *testing.T) {
120+
t.Parallel()
116121
content := `---
117122
engine: copilot
118123
mcp-servers:
@@ -151,6 +156,7 @@ mcp-servers:
151156
})
152157

153158
t.Run("does not modify when no mode field exists", func(t *testing.T) {
159+
t.Parallel()
154160
content := `---
155161
engine: copilot
156162
mcp-servers:
@@ -179,6 +185,7 @@ mcp-servers:
179185
})
180186

181187
t.Run("preserves comments and formatting", func(t *testing.T) {
188+
t.Parallel()
182189
content := `---
183190
engine: copilot
184191
mcp-servers:

pkg/cli/codemod_permissions_test.go

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

1212
func TestGetPermissionsReadCodemod(t *testing.T) {
13+
t.Parallel()
1314
codemod := getExpandPermissionsShorthandCodemod()
1415

1516
assert.Equal(t, "permissions-read-to-read-all", codemod.ID)
@@ -20,6 +21,7 @@ func TestGetPermissionsReadCodemod(t *testing.T) {
2021
}
2122

2223
func TestPermissionsReadCodemod_Read(t *testing.T) {
24+
t.Parallel()
2325
codemod := getExpandPermissionsShorthandCodemod()
2426

2527
content := `---
@@ -43,6 +45,7 @@ permissions: read
4345
}
4446

4547
func TestPermissionsReadCodemod_Write(t *testing.T) {
48+
t.Parallel()
4649
codemod := getExpandPermissionsShorthandCodemod()
4750

4851
content := `---
@@ -66,6 +69,7 @@ permissions: write
6669
}
6770

6871
func TestPermissionsReadCodemod_NoChange_ReadAll(t *testing.T) {
72+
t.Parallel()
6973
codemod := getExpandPermissionsShorthandCodemod()
7074

7175
content := `---
@@ -88,6 +92,7 @@ permissions: read-all
8892
}
8993

9094
func TestPermissionsReadCodemod_NoChange_WriteAll(t *testing.T) {
95+
t.Parallel()
9196
codemod := getExpandPermissionsShorthandCodemod()
9297

9398
content := `---
@@ -110,6 +115,7 @@ permissions: write-all
110115
}
111116

112117
func TestPermissionsReadCodemod_NoChange_MapFormat(t *testing.T) {
118+
t.Parallel()
113119
codemod := getExpandPermissionsShorthandCodemod()
114120

115121
content := `---
@@ -137,6 +143,7 @@ permissions:
137143
}
138144

139145
func TestPermissionsReadCodemod_NoPermissions(t *testing.T) {
146+
t.Parallel()
140147
codemod := getExpandPermissionsShorthandCodemod()
141148

142149
content := `---
@@ -159,6 +166,7 @@ timeout-minutes: 30
159166
}
160167

161168
func TestPermissionsReadCodemod_PreservesMarkdown(t *testing.T) {
169+
t.Parallel()
162170
codemod := getExpandPermissionsShorthandCodemod()
163171

164172
content := `---
@@ -184,6 +192,7 @@ This workflow needs permissions.`
184192
}
185193

186194
func TestGetWritePermissionsCodemod(t *testing.T) {
195+
t.Parallel()
187196
codemod := getMigrateWritePermissionsToReadCodemod()
188197

189198
assert.Equal(t, "write-permissions-to-read-migration", codemod.ID)
@@ -194,6 +203,7 @@ func TestGetWritePermissionsCodemod(t *testing.T) {
194203
}
195204

196205
func TestWritePermissionsCodemod_ShorthandWriteAll(t *testing.T) {
206+
t.Parallel()
197207
codemod := getMigrateWritePermissionsToReadCodemod()
198208

199209
content := `---
@@ -217,6 +227,7 @@ permissions: write-all
217227
}
218228

219229
func TestWritePermissionsCodemod_ShorthandWrite(t *testing.T) {
230+
t.Parallel()
220231
codemod := getMigrateWritePermissionsToReadCodemod()
221232

222233
content := `---
@@ -240,6 +251,7 @@ permissions: write
240251
}
241252

242253
func TestWritePermissionsCodemod_MapFormat(t *testing.T) {
254+
t.Parallel()
243255
codemod := getMigrateWritePermissionsToReadCodemod()
244256

245257
content := `---
@@ -269,6 +281,7 @@ permissions:
269281
}
270282

271283
func TestWritePermissionsCodemod_MultipleWritePermissions(t *testing.T) {
284+
t.Parallel()
272285
codemod := getMigrateWritePermissionsToReadCodemod()
273286

274287
content := `---
@@ -300,6 +313,7 @@ permissions:
300313
}
301314

302315
func TestWritePermissionsCodemod_NoPermissionsField(t *testing.T) {
316+
t.Parallel()
303317
codemod := getMigrateWritePermissionsToReadCodemod()
304318

305319
content := `---
@@ -322,6 +336,7 @@ timeout-minutes: 30
322336
}
323337

324338
func TestWritePermissionsCodemod_OnlyReadPermissions(t *testing.T) {
339+
t.Parallel()
325340
codemod := getMigrateWritePermissionsToReadCodemod()
326341

327342
content := `---
@@ -349,6 +364,7 @@ permissions:
349364
}
350365

351366
func TestWritePermissionsCodemod_PreservesIndentation(t *testing.T) {
367+
t.Parallel()
352368
codemod := getMigrateWritePermissionsToReadCodemod()
353369

354370
content := `---
@@ -377,6 +393,7 @@ permissions:
377393
}
378394

379395
func TestWritePermissionsCodemod_PreservesComments(t *testing.T) {
396+
t.Parallel()
380397
codemod := getMigrateWritePermissionsToReadCodemod()
381398

382399
content := `---
@@ -405,6 +422,7 @@ permissions:
405422
}
406423

407424
func TestWritePermissionsCodemod_PreservesMarkdown(t *testing.T) {
425+
t.Parallel()
408426
codemod := getMigrateWritePermissionsToReadCodemod()
409427

410428
content := `---
@@ -430,6 +448,7 @@ This workflow needs permissions.`
430448
}
431449

432450
func TestWritePermissionsCodemod_SkipsIdToken(t *testing.T) {
451+
t.Parallel()
433452
codemod := getMigrateWritePermissionsToReadCodemod()
434453

435454
content := `---
@@ -459,6 +478,7 @@ permissions:
459478
}
460479

461480
func TestWritePermissionsCodemod_SkipsCopilotRequests(t *testing.T) {
481+
t.Parallel()
462482
codemod := getMigrateWritePermissionsToReadCodemod()
463483

464484
content := `---
@@ -488,6 +508,7 @@ permissions:
488508
}
489509

490510
func TestWritePermissionsCodemod_MixedWithIdToken(t *testing.T) {
511+
t.Parallel()
491512
codemod := getMigrateWritePermissionsToReadCodemod()
492513

493514
content := `---
@@ -521,6 +542,7 @@ permissions:
521542
}
522543

523544
func TestWritePermissionsCodemod_MixedWithCopilotRequests(t *testing.T) {
545+
t.Parallel()
524546
codemod := getMigrateWritePermissionsToReadCodemod()
525547

526548
content := `---

0 commit comments

Comments
 (0)