Skip to content

Commit 29337a0

Browse files
committed
test: cover recover-history help guard
1 parent 60aad9f commit 29337a0

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

‎src/cli.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ function printSubcommandUsage(name: string | undefined): void {
6060
case "eject":
6161
console.log(`Usage: ocx ${name}\n\nRestore native Codex config without stopping the proxy.`);
6262
break;
63+
case "recover-history":
64+
console.log("Usage: ocx recover-history --legacy-openai\n\nExplicitly recover pre-backup syncResumeHistory rows.");
65+
break;
6366
case "uninstall":
6467
case "remove":
6568
console.log(`Usage: ocx ${name}\n\nRemove service/shim/config and restore native Codex.`);

‎tests/cli-help.test.ts‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, expect, test } from "bun:test";
22
import { spawnSync } from "node:child_process";
3-
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
3+
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
44
import { tmpdir } from "node:os";
55
import { dirname, join } from "node:path";
66
import { fileURLToPath } from "node:url";
@@ -37,4 +37,26 @@ describe("CLI subcommand help", () => {
3737
rmSync(codexHome, { recursive: true, force: true });
3838
}
3939
});
40+
41+
test("recover-history --help prints usage without opening history database", () => {
42+
const codexHome = mkdtempSync(join(tmpdir(), "ocx-help-"));
43+
try {
44+
const statePath = join(codexHome, "state_5.sqlite");
45+
46+
const result = spawnSync(process.execPath, [cliPath, "recover-history", "--help"], {
47+
cwd: repoRoot,
48+
env: { ...process.env, CODEX_HOME: codexHome },
49+
encoding: "utf8",
50+
});
51+
52+
expect(result.status).toBe(0);
53+
expect(result.stdout).toContain("Usage: ocx recover-history --legacy-openai");
54+
expect(result.stdout).toContain("Explicitly recover pre-backup syncResumeHistory rows.");
55+
expect(result.stdout).not.toContain("Recovered");
56+
expect(result.stderr).toBe("");
57+
expect(existsSync(statePath)).toBe(false);
58+
} finally {
59+
rmSync(codexHome, { recursive: true, force: true });
60+
}
61+
});
4062
});

0 commit comments

Comments
 (0)