mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-16 10:15:10 +00:00
fix(codex-auth): reject stray profile args
This commit is contained in:
1 parent
85521018bf
commit
c90b3cb9da
4 files changed
+98
-8
No files matched your search
@@ -146,6 +146,42 @@ describe('handleRemoveCodex — only profile', () => {
|
||||
// ── confirmation prompt ───────────────────────────────────────────────────────
|
||||
|
||||
describe('handleRemoveCodex — confirmation', () => {
|
||||
it('rejects extra positional arguments before deleting anything', async () => {
|
||||
const { handleRemoveCodex } = await import(
|
||||
'../../../../src/codex-auth/commands/remove-command'
|
||||
);
|
||||
const ctx = await makeCtx('work');
|
||||
|
||||
let exitCode = -1;
|
||||
const err: string[] = [];
|
||||
const origExit = process.exit;
|
||||
const origError = console.error;
|
||||
const origWrite = process.stderr.write.bind(process.stderr);
|
||||
process.exit = (code?: number) => {
|
||||
exitCode = code ?? 0;
|
||||
throw new Error('exit');
|
||||
};
|
||||
console.error = (...a: unknown[]) => err.push(a.join(' '));
|
||||
process.stderr.write = (chunk: string | Uint8Array) => {
|
||||
err.push(String(chunk));
|
||||
return true;
|
||||
};
|
||||
|
||||
try {
|
||||
await handleRemoveCodex(ctx, ['work', 'accidental', '--yes']);
|
||||
} catch {
|
||||
/* process.exit */
|
||||
} finally {
|
||||
process.exit = origExit;
|
||||
console.error = origError;
|
||||
process.stderr.write = origWrite;
|
||||
}
|
||||
|
||||
expect(exitCode).toBeGreaterThan(0);
|
||||
expect(ctx.registry.hasProfile('work')).toBe(true);
|
||||
expect(err.join('')).toContain('Unexpected arguments: "accidental"');
|
||||
});
|
||||
|
||||
it('cancels when user declines confirmation', async () => {
|
||||
await mockConfirmNo();
|
||||
const { handleRemoveCodex } = await import(
|
||||
|
||||
Reference in new issue
Block a user