test: cover typed timeout mapping in query dispatch
This commit is contained in:
@@ -3,9 +3,9 @@ import { mkdir, rm, writeFile } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { createRegistry } from './index.js';
|
||||
import { GSDToolsError } from '../gsd-tools-error.js';
|
||||
import { runQueryDispatch } from './query-dispatch.js';
|
||||
import { createCommandTopology } from './command-topology.js';
|
||||
|
||||
describe('runQueryDispatch', () => {
|
||||
let tmpDir: string;
|
||||
let fixtureDir: string;
|
||||
@@ -152,6 +152,24 @@ describe('runQueryDispatch', () => {
|
||||
expect(out.error.details).toMatchObject({ command: 'state.load', args: [], timeout_ms: 30000 });
|
||||
});
|
||||
|
||||
it('maps typed native timeout to native_timeout kind with details', async () => {
|
||||
const registry = createRegistry();
|
||||
const out = await runQueryDispatch({
|
||||
registry,
|
||||
projectDir: tmpDir,
|
||||
cjsFallbackEnabled: true,
|
||||
resolveGsdToolsPath: () => '',
|
||||
dispatchNative: async () => { throw GSDToolsError.timeout('timed out', 'state', ['load'], '', 30000); },
|
||||
topology: createCommandTopology(registry),
|
||||
}, ['state', 'load']);
|
||||
|
||||
expect(out.ok).toBe(false);
|
||||
if (out.ok) throw new Error('expected failure');
|
||||
expect(out.error.kind).toBe('native_timeout');
|
||||
expect(out.error.code).toBe(1);
|
||||
expect(out.error.details).toMatchObject({ command: 'state.load', args: [], timeout_ms: 30000 });
|
||||
});
|
||||
|
||||
it('maps native error to native_failure kind with details', async () => {
|
||||
const registry = createRegistry();
|
||||
const out = await runQueryDispatch({
|
||||
|
||||
Reference in New Issue
Block a user