* feat(sdk): deepen compatibility seam for legacy profile path * chore(changeset): set PR number for #3419 * test(sdk): make query seam wiring assertion behavioral
34 lines
1.4 KiB
TypeScript
34 lines
1.4 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { GSDToolsError } from '../gsd-tools-error.js';
|
|
import { buildQueryCliOutputFromError } from './query-cli-output.js';
|
|
|
|
describe('query-cli-output', () => {
|
|
it('prefers raw gsd-tools stderr when present', () => {
|
|
const err = GSDToolsError.failure('failed', 'list', ['json'], 2, 'line one\nline two\n');
|
|
const out = buildQueryCliOutputFromError(err);
|
|
expect(out.exitCode).toBe(2);
|
|
expect(out.stderrLines).toEqual(['line one', 'line two']);
|
|
});
|
|
|
|
it('falls back to Error: message when gsd-tools stderr is empty', () => {
|
|
const err = GSDToolsError.failure('failed', 'list', ['json'], null, '');
|
|
const out = buildQueryCliOutputFromError(err);
|
|
expect(out.exitCode).toBe(1);
|
|
expect(out.stderrLines).toEqual(['Error: failed']);
|
|
});
|
|
|
|
it('falls back to Error: message when gsd-tools stderr is whitespace-only', () => {
|
|
const err = GSDToolsError.failure('failed', 'build', ['json'], null, ' \n');
|
|
const out = buildQueryCliOutputFromError(err);
|
|
expect(out.exitCode).toBe(1);
|
|
expect(out.stderrLines).toEqual(['Error: failed']);
|
|
});
|
|
|
|
it('uses exitCode 1 when gsd-tools exitCode is null and stderr is non-empty', () => {
|
|
const err = GSDToolsError.failure('failed', 'build', ['json'], null, 'line');
|
|
const out = buildQueryCliOutputFromError(err);
|
|
expect(out.exitCode).toBe(1);
|
|
expect(out.stderrLines).toEqual(['line']);
|
|
});
|
|
});
|