refactor: deepen GSDTools query execution seams (#3085)
* refactor: deepen gsdtools query execution seams * docs: add changeset for query seam deepening * docs: fix changeset summary text * fix: address coderabbit query seam findings * test: address remaining coderabbit findings and notes * refactor: use internal gsdtools error type import
This commit is contained in:
31
sdk/src/query-execution-policy.test.ts
Normal file
31
sdk/src/query-execution-policy.test.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { describe, it, expect, vi, afterEach } from 'vitest';
|
||||
import { QueryExecutionPolicy } from './query-execution-policy.js';
|
||||
import { setTransportPolicy, clearTransportPolicy } from './gsd-transport-policy.js';
|
||||
|
||||
describe('QueryExecutionPolicy', () => {
|
||||
afterEach(() => {
|
||||
clearTransportPolicy();
|
||||
});
|
||||
|
||||
it('applies transport policy to transport.run', async () => {
|
||||
const run = vi.fn().mockResolvedValue({ ok: true });
|
||||
const policy = new QueryExecutionPolicy({ run } as never);
|
||||
|
||||
setTransportPolicy('verify.path-exists', { preferNative: true, allowFallbackToSubprocess: false });
|
||||
|
||||
await policy.execute({
|
||||
legacyCommand: 'verify.path-exists',
|
||||
legacyArgs: [],
|
||||
registryCommand: 'verify.path-exists',
|
||||
registryArgs: [],
|
||||
mode: 'json',
|
||||
projectDir: '/tmp/project',
|
||||
preferNativeQuery: true,
|
||||
});
|
||||
|
||||
expect(run).toHaveBeenCalledTimes(1);
|
||||
const [, policyArg] = run.mock.calls[0];
|
||||
expect(policyArg).toEqual({ preferNative: true, allowFallbackToSubprocess: false });
|
||||
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user