package config import ( "os" "testing" "github.com/rs/zerolog" ) // TestMain quiets the global zerolog level for the duration of the test // suite. Rationale (Q-038, 2026-05-05): viper's internal watcher goroutine // (started by viper.WatchConfig in WatchAndApply) has no public Stop and // can outlive a test's context. Any log call from a leaked goroutine // races with the next test's LoadConfig → SetupLogging → // zerolog.SetGlobalLevel under `go test -race`. Disabling the logger here // is the root-cause fix: the racing memory location is zerolog's gLevel // global, and if no log call ever evaluates against it we sidestep the // race entirely without changing production behavior. // // In production, log calls happen against an unchanging global level // (SetupLogging runs once at startup), so the race condition does not // occur there. func TestMain(m *testing.M) { zerolog.SetGlobalLevel(zerolog.Disabled) os.Exit(m.Run()) }