MCPcopy Index your code
hub / github.com/docker/docker-agent / TestMain

Function TestMain

pkg/httpclient/client_test.go:23–37  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

21// never mutated, so it stays safe for parallel tests. Tests needing a
22// deterministic UUID inject their own resolver via [withCagentIDSource].
23func 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
39func TestHeaders(t *testing.T) {
40 t.Parallel()

Callers

nothing calls this directly

Calls 2

SetConfigDirFunction · 0.92
RunMethod · 0.65

Tested by

no test coverage detected