TestMain points the config dir used by the default [userid.Get] at a throw-away temp dir so tests exercising gateway-bound requests never read or write the real user-uuid file. The override is set once and never mutated, so it stays safe for parallel tests. Tests needing a deterministic UUID inject
(m *testing.M)
| 21 | // never mutated, so it stays safe for parallel tests. Tests needing a |
| 22 | // deterministic UUID inject their own resolver via [withCagentIDSource]. |
| 23 | func TestMain(m *testing.M) { |
| 24 | //nolint:forbidigo // TestMain has no *testing.T, so t.TempDir is unavailable. |
| 25 | dir, err := os.MkdirTemp("", "httpclient-test-config-*") |
| 26 | if err != nil { |
| 27 | panic(err) |
| 28 | } |
| 29 | |
| 30 | paths.SetConfigDir(dir) |
| 31 | |
| 32 | code := m.Run() |
| 33 | |
| 34 | paths.SetConfigDir("") |
| 35 | _ = os.RemoveAll(dir) |
| 36 | os.Exit(code) |
| 37 | } |
| 38 | |
| 39 | func TestHeaders(t *testing.T) { |
| 40 | t.Parallel() |
nothing calls this directly
no test coverage detected