mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-10-11 03:38:07 +00:00
test(cli): assert the force-exit forwards process.exitCode, not a hardcoded 1 (#2264)
The existing cases asserted process.exit(1), but since the error catch always sets exitCode=1 they couldn't distinguish forwarding (process.exit(process.exitCode ?? 1)) from a hardcoded 1. Add a case on the alreadyUpToDate path — which returns without setting exitCode or calling process.exit — with a pre-set exitCode=2 and isLbugReady forced true, asserting the wrapper force-exits with 2. Proves the exitCode-forwarding branch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JBJomjoTdBV2eveDVq4JMm
This commit is contained in:
parent
cdc3f93449
commit
8ee17efc34
1 changed files with 21 additions and 0 deletions
|
|
@ -155,4 +155,25 @@ describe('analyzeCommand — finalize-failure must terminate, not hang (#2264 P1
|
|||
expect(exitSpy).not.toHaveBeenCalled();
|
||||
expect(process.exitCode).toBe(1);
|
||||
});
|
||||
|
||||
it('forwards a pre-set process.exitCode rather than the hardcoded fallback', async () => {
|
||||
// The alreadyUpToDate path returns WITHOUT setting process.exitCode or calling
|
||||
// process.exit (unlike the error catch, which always sets exitCode=1), so the
|
||||
// wrapper's force-exit must forward whatever exitCode is already set — proving
|
||||
// `process.exit(process.exitCode ?? 1)` reads exitCode and doesn't hardcode 1.
|
||||
// isLbugReady is forced true to drive the wrapper's force-exit on this path.
|
||||
isLbugReadyMock.mockReturnValue(true);
|
||||
runFullAnalysisMock.mockResolvedValue({
|
||||
repoName: 'repo',
|
||||
repoPath: '/repo',
|
||||
stats: {},
|
||||
alreadyUpToDate: true,
|
||||
ftsRepairedOnly: false,
|
||||
pipelineResult: { communityResult: undefined },
|
||||
});
|
||||
assertAnalysisFinalizedMock.mockResolvedValue(undefined);
|
||||
process.exitCode = 2;
|
||||
await analyzeCommand(undefined, {});
|
||||
expect(exitSpy).toHaveBeenCalledWith(2);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue