Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions cli/tests/helpers/telemetry-sandbox.integration.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { rmSync } from "node:fs";
import { afterEach, describe, expect, it } from "vitest";
import { createTelemetrySandbox } from "./telemetry-sandbox.js";

describe("the telemetry sandbox's git environment", () => {
const saved = { claude: process.env.CLAUDE_CODE_SESSION_ID, codex: process.env.CODEX_THREAD_ID };
afterEach(() => {
for (const [name, value] of [
["CLAUDE_CODE_SESSION_ID", saved.claude],
["CODEX_THREAD_ID", saved.codex],
] as const) {
if (value === undefined) delete process.env[name];
else process.env[name] = value;
}
});

it("hands a git hook no session of the process running the tests", () => {
process.env.CLAUDE_CODE_SESSION_ID = "runner-claude-session";
process.env.CODEX_THREAD_ID = "runner-codex-thread";
const box = createTelemetrySandbox();
try {
expect(box.gitEnv.CLAUDE_CODE_SESSION_ID).toBe("");
expect(box.gitEnv.CODEX_THREAD_ID).toBe("");
} finally {
rmSync(box.root, { recursive: true, force: true });
}
});
});
7 changes: 6 additions & 1 deletion cli/tests/helpers/telemetry-sandbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ export function createTelemetrySandbox(): TelemetrySandbox {
for (const dir of [home, claude]) mkdirSync(dir, { recursive: true });
assertUnderTemporaryDirectory([root, home, telemetry, claude]);
writeFileSync(join(home, ".gitconfig"), "");
const gitEnv = sandboxGitEnv(home, { GIT_CONFIG_GLOBAL: join(home, ".gitconfig") });
// A hook git runs reads the session from these: the runner's own must not reach a commit.
const gitEnv = sandboxGitEnv(home, {
GIT_CONFIG_GLOBAL: join(home, ".gitconfig"),
CLAUDE_CODE_SESSION_ID: "",
CODEX_THREAD_ID: "",
});
return {
root,
home,
Expand Down
Loading