Skip to content

Commit b3c9f90

Browse files
test: keep the id-properties test clear of the telemetry disable flags
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE
1 parent e463fa7 commit b3c9f90

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎packages/opencode/test/altimate/telemetry/id-properties.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,19 @@ describe("numeric ids are envelope properties, not measurements", () => {
1010
let fetchSpy: ReturnType<typeof spyOn>
1111
let homedirSpy: ReturnType<typeof spyOn>
1212
let savedCs: string | undefined
13+
// Either disable flag wins over the connection string, so a developer or CI environment that
14+
// sets one would fail the envelope assertions; cleared here and restored after.
15+
const DISABLE_FLAGS = ["ALTIMATE_TELEMETRY_DISABLED", "OPENCODE_DISABLE_TELEMETRY"] as const
16+
let savedFlags: Record<string, string | undefined>
1317

1418
beforeEach(() => {
1519
home = mkdtempSync(path.join(os.tmpdir(), "telemetry-ids-"))
1620
savedCs = process.env.APPLICATIONINSIGHTS_CONNECTION_STRING
21+
savedFlags = {}
22+
for (const flag of DISABLE_FLAGS) {
23+
savedFlags[flag] = process.env[flag]
24+
delete process.env[flag]
25+
}
1726
process.env.APPLICATIONINSIGHTS_CONNECTION_STRING =
1827
"InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://ingest.example.invalid/"
1928
homedirSpy = spyOn(os, "homedir").mockImplementation(() => home)
@@ -31,6 +40,10 @@ describe("numeric ids are envelope properties, not measurements", () => {
3140
homedirSpy.mockRestore()
3241
if (savedCs === undefined) delete process.env.APPLICATIONINSIGHTS_CONNECTION_STRING
3342
else process.env.APPLICATIONINSIGHTS_CONNECTION_STRING = savedCs
43+
for (const flag of DISABLE_FLAGS) {
44+
if (savedFlags[flag] === undefined) delete process.env[flag]
45+
else process.env[flag] = savedFlags[flag]
46+
}
3447
rmSync(home, { recursive: true, force: true })
3548
})
3649

0 commit comments

Comments
 (0)