Skip to content

Commit fae70ee

Browse files
committed
test(auth): cover EBUSY graceful fallback on backup assessment
Verify that when getActionableNamedBackupRestores throws EBUSY the login flow falls through to OAuth instead of crashing.
1 parent b7b629a commit fae70ee

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

test/codex-manager-cli.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,29 @@ describe("codex manager cli commands", () => {
567567
expect(createAuthorizationFlowMock).not.toHaveBeenCalled();
568568
});
569569

570+
it("falls through to OAuth when backup assessment throws EBUSY", async () => {
571+
setInteractiveTTY(true);
572+
loadAccountsMock.mockResolvedValue({
573+
version: 3,
574+
activeIndex: 0,
575+
activeIndexByFamily: { codex: 0 },
576+
accounts: [],
577+
});
578+
const ebusy = Object.assign(new Error("EBUSY: resource busy"), {
579+
code: "EBUSY",
580+
});
581+
getActionableNamedBackupRestoresMock.mockRejectedValueOnce(ebusy);
582+
selectMock.mockResolvedValueOnce("cancel");
583+
584+
const { runCodexMultiAuthCli } = await import("../lib/codex-manager.js");
585+
const exitCode = await runCodexMultiAuthCli(["auth", "login"]);
586+
587+
expect(exitCode).toBe(0);
588+
expect(getActionableNamedBackupRestoresMock).toHaveBeenCalledTimes(1);
589+
expect(confirmMock).not.toHaveBeenCalled();
590+
expect(createAuthorizationFlowMock).toHaveBeenCalledTimes(1);
591+
});
592+
570593
it("skips startup restore prompt in fallback login mode", async () => {
571594
setInteractiveTTY(true);
572595
isInteractiveLoginMenuAvailableMock.mockReturnValue(false);

0 commit comments

Comments
 (0)