The package-level mockp is shared across tests in internal/server. MockProvider.Subscribe runs in a goroutine that defers a 500ms sleep before returning, so that goroutine can outlive the test that triggered it. Its read/reset of MockMessages then races against the next test's Subscribe goroutine when -race is enabled.
The slice should be encapsulated behind synchronization (e.g. a sync.Mutex plus SetMockMessages / takeMockMessages helpers) so concurrent tests can't observe or mutate it without coordination.
The package-level
mockpis shared across tests ininternal/server.MockProvider.Subscriberuns in a goroutine that defers a 500ms sleep before returning, so that goroutine can outlive the test that triggered it. Its read/reset ofMockMessagesthen races against the next test'sSubscribegoroutine when-raceis enabled.The slice should be encapsulated behind synchronization (e.g. a
sync.MutexplusSetMockMessages/takeMockMessageshelpers) so concurrent tests can't observe or mutate it without coordination.