|
1 | 1 | import { describe, expect, test } from "bun:test"; |
2 | 2 | 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"; |
4 | 4 | import { tmpdir } from "node:os"; |
5 | 5 | import { dirname, join } from "node:path"; |
6 | 6 | import { fileURLToPath } from "node:url"; |
@@ -37,4 +37,26 @@ describe("CLI subcommand help", () => { |
37 | 37 | rmSync(codexHome, { recursive: true, force: true }); |
38 | 38 | } |
39 | 39 | }); |
| 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 | + }); |
40 | 62 | }); |
0 commit comments