Skip to content

Commit 29f68e0

Browse files
committed
test(042): clear CI/DO_NOT_TRACK env in heartbeat tests
TestHeartbeatSend and TestMultipleHeartbeats instantiate the telemetry service, which captures the env-var disable reason at New() time. GitHub Actions sets CI=true, which caused Start() to early-return before sending any heartbeats — failing both tests on CI but passing locally. Use t.Setenv to clear CI, DO_NOT_TRACK, and MCPPROXY_TELEMETRY for the duration of these tests so telemetry actually runs. Other tests in the package don't call Start() so they're unaffected. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0f74e52 commit 29f68e0

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

internal/telemetry/telemetry_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ func (m *mockRuntimeStats) GetRoutingMode() string { return m.routingMode
3030
func (m *mockRuntimeStats) IsQuarantineEnabled() bool { return m.quarantine }
3131

3232
func TestHeartbeatSend(t *testing.T) {
33+
// Clear env vars that would disable telemetry (GitHub Actions sets CI=true).
34+
t.Setenv("CI", "")
35+
t.Setenv("DO_NOT_TRACK", "")
36+
t.Setenv("MCPPROXY_TELEMETRY", "")
37+
3338
var received atomic.Int32
3439
var lastPayload HeartbeatPayload
3540

@@ -242,6 +247,11 @@ func TestEnsureAnonymousID(t *testing.T) {
242247
}
243248

244249
func TestMultipleHeartbeats(t *testing.T) {
250+
// Clear env vars that would disable telemetry (GitHub Actions sets CI=true).
251+
t.Setenv("CI", "")
252+
t.Setenv("DO_NOT_TRACK", "")
253+
t.Setenv("MCPPROXY_TELEMETRY", "")
254+
245255
var received atomic.Int32
246256

247257
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)