test(cli): persist warehouse connection in sl query tests (#303)

#301 strengthened resolveLocalConnectionId to reject connections absent
from ktx.yaml, but three sl query tests configured the warehouse
connection only in memory while runKtxSl reloads the project from disk,
so they returned exit code 1 once the check landed on main. Persist the
connection to ktx.yaml so it survives the reload and the tests exercise
the real on-disk load path.
This commit is contained in:
Andrey Avtomonov 2026-06-15 17:23:59 +02:00 committed by GitHub
parent 6c815ef529
commit fde9f9862d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -618,6 +618,15 @@ joins: []
vi.stubEnv('CI', '');
const projectDir = join(tempDir, 'project');
await seedSlSource({ projectDir });
const config = parseKtxProjectConfig(await readFile(join(projectDir, 'ktx.yaml'), 'utf-8'));
await writeFile(
join(projectDir, 'ktx.yaml'),
serializeKtxProjectConfig({
...config,
connections: { ...config.connections, warehouse: { driver: 'postgres' } },
}),
'utf-8',
);
const io = makeIo({ isTTY: true });
const createSemanticLayerCompute = vi.fn(() => ({
query: vi.fn(async () => ({
@ -654,6 +663,7 @@ joins: []
const projectDir = join(tempDir, 'project');
const project = await initKtxProject({ projectDir });
project.config.connections.warehouse = { driver: 'postgres' };
await writeFile(join(projectDir, 'ktx.yaml'), serializeKtxProjectConfig(project.config), 'utf-8');
await project.fileStore.writeFile(
'semantic-layer/warehouse/orders.yaml',
`name: orders
@ -721,6 +731,7 @@ joins: []
const projectDir = join(tempDir, 'project');
const project = await initKtxProject({ projectDir });
project.config.connections.warehouse = { driver: 'postgres' };
await writeFile(join(projectDir, 'ktx.yaml'), serializeKtxProjectConfig(project.config), 'utf-8');
await project.fileStore.writeFile(
'semantic-layer/warehouse/orders.yaml',
`name: orders