Skip to content

Commit 30ce18e

Browse files
committed
tests: copy attr per subtest to avoid data race on parallel tests
Each parallel subtest needs its own copy of the Attributes struct since NewTestState mutates the tag field via the shared pointer. Without the copy, both HTTP and SSH subtests would race on writing attr.tag. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
1 parent fb04bd1 commit 30ce18e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

test/gomod_git_auth_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ go {{ .ModFileGoVersion }}
104104
ctx := startTestSpan(baseCtx, t)
105105

106106
testEnv.RunTest(ctx, t, func(ctx context.Context, client gwclient.Client) {
107+
attr := attr
107108
testState := gitservices.NewTestState(t, client, &attr)
108109

109110
worker, _, gitHost := initStates(&testState)
@@ -161,6 +162,7 @@ go {{ .ModFileGoVersion }}
161162
agentErrChan := startSSHAgent(t, privkey, sockaddr)
162163

163164
testEnv.RunTest(ctx, t, func(ctx context.Context, client gwclient.Client) {
165+
attr := attr
164166
testState := gitservices.NewTestState(t, client, &attr)
165167

166168
_, repo, gitHost := initStates(&testState)

0 commit comments

Comments
 (0)