Repository navigation
test: init guard coverage follow-ups (PR #48 review F1/F2) - #50
Conversation
Close the two non-blocking LOW coverage findings from the APPROVE review of PR #48 (issue #41 init overwrite guard): F1 -- no `--yes` + non-TTY combined test. Add a case running `init({ yes: true })` with a non-TTY stdin: confirm() is never called, the existing config is overwritten, and init resolves cleanly. Pins the invariant that `--yes` short-circuits the guard before the `!process.stdin.isTTY` check is reached. F2 -- existence-check non-ENOENT branch untested. Stub only `access` from node:fs/promises (all other fs ops stay real via importOriginal); the default stub replicates real `access(path, F_OK)` (ENOENT when absent) so every other test keeps its real-fs behavior. The new case makes `access` reject with an EACCES-coded error and asserts init rejects without writing. Verified: pnpm install && build && typecheck && lint && test all green (1045 core tests). Mutation-checked both new tests against the exact regressions they guard (each fails when its invariant breaks).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review: APPROVEReviewed the diff against merge-base Live-verified, not assumed: re-ran the sanctioned single-file suite at the PR head — What the tests do right
The four review asks
No findings (none CRITICAL / HIGH / MEDIUM / LOW). The two LOWs from the #48 review are now closed by tests with demonstrated teeth. Approving. Ready for the merge-only tail. |
What this does
Closes the two non-blocking LOW test-coverage findings from the APPROVE review of PR #48 (the issue #41 init-overwrite-guard fix). Both are follow-ups that add missing coverage — no production code changes.
Findings addressed
F1 —
--yes+ non-TTY combined test (was untested)init({ yes: true })previously only ran with a TTY stdin. Added a case with a non-TTY stdin that assertsconfirm()is never called, the existing config is overwritten, andinit()resolves cleanly. Pins the invariant that--yesshort-circuits the guard before the!process.stdin.isTTYcheck is reached, guarding against a future refactor that moves the TTY check outside the!options.yesguard.F2 — existence-check non-
ENOENTbranch untestedinit.tselse { throw error }(the existence check) was not covered — only the prompt-path error surfacing was. Stubbed onlyaccessfromnode:fs/promises(all other fs ops stay real viaimportOriginal); the default stub replicates realaccess(path, F_OK)so every existing test keeps its real-fs behavior. The new case makesaccessreject with anEACCES-coded error and assertsinit()rejects without writing.Verification
pnpm install && pnpm build && pnpm typecheck && pnpm lint && pnpm test(1045 core tests pass).--yesguard) and passes when restored.pnpm --dir packages/core exec vitest run src/commands/__tests__/init.test.ts→ 8 passed.Provenance: #48 (comment)