This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user