Skip to content
Closed
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
4 changes: 2 additions & 2 deletions lib/codex-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
loadCodexCliState,
} from "./codex-cli/state.js";
import { setCodexCliActiveSelection } from "./codex-cli/writer.js";
import { runCheckCommand } from "./codex-manager/commands/check.js";
import {
runFeaturesCommand,
runStatusCommand,
Expand Down Expand Up @@ -5547,8 +5548,7 @@ export async function runCodexMultiAuthCli(rawArgs: string[]): Promise<number> {
return runSwitch(rest);
}
if (command === "check") {
await runHealthCheck({ liveProbe: true });
return 0;
return runCheckCommand({ runHealthCheck });
}
if (command === "features") {
return runFeaturesReport();
Expand Down
8 changes: 8 additions & 0 deletions lib/codex-manager/commands/check.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export interface CheckCommandDeps {
runHealthCheck: (options: { liveProbe: boolean }) => Promise<void>;
}

export async function runCheckCommand(deps: CheckCommandDeps): Promise<number> {
await deps.runHealthCheck({ liveProbe: true });
return 0;
}
32 changes: 32 additions & 0 deletions test/codex-manager-check-command.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { describe, expect, it, vi } from "vitest";
import {
type CheckCommandDeps,
runCheckCommand,
} from "../lib/codex-manager/commands/check.js";

describe("runCheckCommand", () => {
it("runs health check with live probing enabled", async () => {
const deps: CheckCommandDeps = {
runHealthCheck: vi.fn(async () => undefined),
};

const result = await runCheckCommand(deps);

expect(result).toBe(0);
expect(deps.runHealthCheck).toHaveBeenCalledTimes(1);
expect(deps.runHealthCheck).toHaveBeenCalledWith({ liveProbe: true });
});

it("propagates rejection from runHealthCheck", async () => {
const error = new Error("probe failed");
const deps: CheckCommandDeps = {
runHealthCheck: vi.fn(async () => {
throw error;
}),
};

await expect(runCheckCommand(deps)).rejects.toThrow("probe failed");
expect(deps.runHealthCheck).toHaveBeenCalledTimes(1);
expect(deps.runHealthCheck).toHaveBeenCalledWith({ liveProbe: true });
});
});