@@ -166,7 +166,7 @@ func TestLabelsMatch(t *testing.T) {
166
166
}
167
167
}
168
168
func TestBranchMatchesCriteria (t * testing.T ) {
169
- t .Parallel ()
169
+ // Remove t.Parallel() at the function level to avoid races on global variables
170
170
171
171
// Define test cases
172
172
tests := []struct {
@@ -263,10 +263,25 @@ func TestBranchMatchesCriteria(t *testing.T) {
263
263
}
264
264
265
265
for _ , test := range tests {
266
+ test := test // Create a local copy of the test variable to use in the closure
266
267
t .Run (test .name , func (t * testing.T ) {
267
- t .Parallel ()
268
+ t .Parallel () // Parallelize at the subtest level, each with their own local variables
269
+
270
+ // Save original values of global variables
271
+ origCombineBranchName := combineBranchName
272
+ origBranchPrefix := branchPrefix
273
+ origBranchSuffix := branchSuffix
274
+ origBranchRegex := branchRegex
275
+
276
+ // Restore original values after test
277
+ defer func () {
278
+ combineBranchName = origCombineBranchName
279
+ branchPrefix = origBranchPrefix
280
+ branchSuffix = origBranchSuffix
281
+ branchRegex = origBranchRegex
282
+ }()
268
283
269
- // Set global variables for the test
284
+ // Set global variables for this specific test
270
285
combineBranchName = test .combineBranch
271
286
branchPrefix = test .prefix
272
287
branchSuffix = test .suffix
0 commit comments