Skip to content

test: add cherry-pick unit tests for pure helpers#848

Merged
jkleinsc merged 2 commits intomainfrom
test/cherry-pick-coverage
Apr 27, 2026
Merged

test: add cherry-pick unit tests for pure helpers#848
jkleinsc merged 2 commits intomainfrom
test/cherry-pick-coverage

Conversation

@codebytere
Copy link
Copy Markdown
Member

Extract splitPositionalArgs, computeBatchId, and formatPRTitleAndBody from the cherry-pick action handler, export the existing isUrl and commitSubject helpers, and gate program.parse() behind import.meta.main so the module is importable from tests. Add tests/e-cherry-pick.spec.mjs covering all five exports.

@codebytere codebytere requested review from a team and ckerr as code owners April 18, 2026 19:15
@dsanders11
Copy link
Copy Markdown
Member

@codebytere, looks like CI is unhappy here.

Copy link
Copy Markdown
Member

@ckerr ckerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the refactor sounds like a good idea, needs another update to get the tests passing

Extract splitPositionalArgs, computeBatchId, and formatPRTitleAndBody
from the cherry-pick action handler, export the existing isUrl and
commitSubject helpers, and gate program.parse() behind import.meta.main
so the module is importable from tests. Add tests/e-cherry-pick.spec.mjs
covering all five exports.
Several src/e-*.ts modules share commander's default `program` singleton.
When tests import more than one of these modules (e.g. parsers.spec.mjs
imports both e-open and e-pr), each module's CLI definitions are
appended to the same shared program. Adding a non-variadic positional
after another module's variadic positional throws ("only the last
argument can be variadic"), and required-argument errors call
process.exit at import time.

Switch e-cherry-pick, e-open, e-pr, and e-rcv to use their own
`new Command()` instance so each module owns its CLI surface and can be
imported safely from the vitest suites.
@codebytere codebytere force-pushed the test/cherry-pick-coverage branch from a301e4b to 5e0b550 Compare April 27, 2026 09:11
@codebytere codebytere requested a review from ckerr April 27, 2026 09:11
@jkleinsc jkleinsc merged commit 14e19ae into main Apr 27, 2026
12 checks passed
@jkleinsc jkleinsc deleted the test/cherry-pick-coverage branch April 27, 2026 20:36
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.

4 participants