mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-11 22:53:04 +00:00
fix(cli): fail cypher errors loudly
This commit is contained in:
parent
c6445096eb
commit
c35fc27427
2 changed files with 32 additions and 0 deletions
|
|
@ -301,6 +301,15 @@ export async function cypherCommand(
|
|||
}
|
||||
}
|
||||
output(result);
|
||||
if (
|
||||
result &&
|
||||
typeof result === 'object' &&
|
||||
'error' in result &&
|
||||
typeof result.error === 'string' &&
|
||||
result.error.trim().length > 0
|
||||
) {
|
||||
process.exitCode = 1;
|
||||
}
|
||||
}
|
||||
|
||||
export async function detectChangesCommand(options?: {
|
||||
|
|
|
|||
|
|
@ -81,6 +81,29 @@ describe('direct CLI tool commands', () => {
|
|||
expect(process.exitCode).toBe(1);
|
||||
});
|
||||
|
||||
it('fails closed when cypher returns a backend error payload', async () => {
|
||||
callToolMock.mockResolvedValue({ error: 'Binder exception: missing relationship property' });
|
||||
const { cypherCommand } = await import('../../src/cli/tool.js');
|
||||
|
||||
await cypherCommand('MATCH ()-[r:CodeRelation]->() RETURN r.missing');
|
||||
|
||||
expect(writeSyncMock).toHaveBeenCalledWith(
|
||||
1,
|
||||
expect.stringContaining('Binder exception: missing relationship property'),
|
||||
);
|
||||
expect(process.exitCode).toBe(1);
|
||||
});
|
||||
|
||||
it('keeps a successful cypher result at exit zero', async () => {
|
||||
callToolMock.mockResolvedValue({ markdown: '| count |\n| --- |\n| 1 |', row_count: 1 });
|
||||
const { cypherCommand } = await import('../../src/cli/tool.js');
|
||||
|
||||
await cypherCommand('MATCH (n) RETURN count(n) AS count');
|
||||
|
||||
expect(writeSyncMock).toHaveBeenCalledWith(1, expect.stringContaining('"row_count": 1'));
|
||||
expect(process.exitCode).toBeUndefined();
|
||||
});
|
||||
|
||||
it('dispatches detect_changes with CLI-shaped arguments', async () => {
|
||||
callToolMock.mockResolvedValue({
|
||||
summary: {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue