Files
coder/coderd/coderdtest
Thomas Kosiewski 70f62ae429 fix(coderd/coderdtest): render the Swagger spec once in parallel tests (#31829)
## Why

`test-go-race-pg` fails on PRs that touch no Go product code, for
example two runs on #31782. Since #30124, two parallel tests in
`coderd/coderdtest` call swag's `Spec.ReadDoc`, which writes shared
state, so the race detector fails the whole package (`WARNING: DATA
RACE` in `swag.(*Spec).ReadDoc`, `swagger_test.go:41` and `:77`).

## What changed

`swagger_test.go` renders the spec once through `sync.OnceValue`, and
both tests read that string.

## Verification

- On `main`, `go test -race -count=20 -run
'TestSwaggerParametersValid|TestChatModelPathParametersFormatted'
./coderd/coderdtest/` reported 4 data races and failed.
- With this change, the same command passed with 0 races.
- `golangci-lint` reports 0 issues for `./coderd/coderdtest/` with both
the main and the new-code configs.

---
_Generated with [`xum`](https://github.com/coder/xum) • Model:
`anthropic:claude-opus-5-5` • Thinking: `high`_
2026-11-09 17:37:35 +11:00
..