Skip to content

test(dor): cover kill's conflicting-confirmation rejection - #369

Open
dormouse-bot wants to merge 1 commit into
mainfrom
test/kill-conflicting-confirmation
Open

test(dor): cover kill's conflicting-confirmation rejection#369
dormouse-bot wants to merge 1 commit into
mainfrom
test/kill-conflicting-confirmation

Conversation

@dormouse-bot

Copy link
Copy Markdown
Collaborator

Nightly survey finding: dor kill's confirmation guard in dor/src/commands/kill.ts rejects whenever the number of supplied confirmation modes is not exactly one:

const confirmations = [
  flags.confirmDangerously === true,
  flags.confirmIfRead !== undefined,
].filter(Boolean).length;
if (confirmations !== 1) {
  return { ok: false, message: 'dor kill requires exactly one confirmation mode' };
}

That single guard covers two distinct inputs — zero modes and two conflicting modes — but only the zero-mode case (kill missing confirmation output) was exercised. The two flags are declared independently (optional: true, no parser-level exclusivity), so --confirm-dangerously --confirm-if-read done together reaches this branch at runtime; nothing pinned that behavior.

This adds a kill conflicting confirmation output test passing both flags. Its output is identical to the missing-confirmation case (same error, same exit), so the snapshot matches byte-for-byte — the value is guarding the mutual-exclusivity contract against a future refactor that might, say, let --confirm-dangerously win silently instead of erroring.

Docs-adjacent, no behavior change. Verified locally: node --test test/*.test.mjs → 100 pass, 0 fail (the new ok 43 - kill conflicting confirmation output included).

parseConfirmation rejects when the number of confirmation modes != 1,
which covers both zero modes and two conflicting modes. Only the
zero-mode case (kill-missing-confirmation) was tested; add a case that
passes both --confirm-dangerously and --confirm-if-read to guard the
two-mode branch.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: f05854c
Status: ✅  Deploy successful!
Preview URL: https://067dbc29.mouseterm.pages.dev
Branch Preview URL: https://test-kill-conflicting-confir.mouseterm.pages.dev

View logs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant