fix(LLM 審查流程): 避免單一角色失敗中止 pipeline
CI / AI Code Review (pull_request) Failing after 7s

This commit is contained in:
2026-06-26 09:26:12 +00:00
parent a62bfbd4b8
commit 6c3e7b9d37
3 changed files with 41 additions and 12 deletions
+9 -5
View File
@@ -85,14 +85,18 @@ describe('chat - OpenCode', async () => {
assert.equal(result, 'hello world');
});
it('calls process.exit(1) when OpenCode fails', async () => {
it('throws an error when OpenCode fails instead of exiting the process', async () => {
process.env.OPENCODE_BASE_URL = 'http://opencode.local:4096';
mock.method(axios, 'post', async () => { throw new Error('fail'); });
const exitMock = mock.method(process, 'exit', () => { throw new Error('exit:1'); });
mock.method(axios, 'post', async () => {
const err = new Error('Request failed with status code 500');
err.response = { status: 500, data: { error: 'provider overloaded' } };
throw err;
});
const exitMock = mock.method(process, 'exit', () => { throw new Error('exit should not be called'); });
await assert.rejects(() => chat('sys', 'user'), /exit:1/);
await assert.rejects(() => chat('sys', 'user'), /HTTP 500.*provider overloaded/);
assert.equal(exitMock.mock.calls[0].arguments[0], 1);
assert.equal(exitMock.mock.calls.length, 0);
});
});