test(cli): verify unified ingest public output

This commit is contained in:
Andrey Avtomonov 2026-05-13 18:55:20 +02:00
parent 0b16578dd5
commit 077a35d307
3 changed files with 12 additions and 8 deletions

View file

@ -44,7 +44,7 @@ export interface ContextBuildArgs {
depth?: Extract<KtxPublicIngestArgs, { command: 'run' }>['depth'];
queryHistory?: Extract<KtxPublicIngestArgs, { command: 'run' }>['queryHistory'];
queryHistoryWindowDays?: number;
scanMode?: 'structural' | 'enriched';
scanMode?: Extract<KtxPublicIngestArgs, { command: 'run' }>['scanMode'];
detectRelationships?: boolean;
}

View file

@ -466,14 +466,15 @@ describe('runKtxPublicIngest', () => {
).resolves.toBe(1);
expect(runIngest).toHaveBeenCalledWith(
{
expect.objectContaining({
command: 'run',
projectDir: '/tmp/project',
connectionId: 'prod_metabase',
adapter: 'metabase',
allowImplicitAdapter: true,
outputMode: 'plain',
inputMode: 'disabled',
},
}),
expect.anything(),
);
expect(runScan).toHaveBeenCalledWith(
@ -550,7 +551,7 @@ describe('runKtxPublicIngest', () => {
detectRelationships: true,
dryRun: false,
},
io.io,
expect.objectContaining({ capturedOutput: expect.any(Function) }),
);
});

View file

@ -1231,9 +1231,11 @@ describe('setup databases step', () => {
const config = parseKtxProjectConfig(await readFile(join(tempDir, 'ktx.yaml'), 'utf-8'));
expect(config.connections.warehouse).toMatchObject({ driver: 'postgres', url: 'env:DATABASE_URL' });
expect(await readFile(join(tempDir, 'ktx.yaml'), 'utf-8')).not.toContain('completed_steps:');
expect(io.stderr()).toContain('Structural scan failed for warehouse.');
expect(io.stderr()).toContain('│ Structural scan failed for warehouse.');
expect(io.stderr()).not.toMatch(/^Structural scan failed for warehouse\./m);
expect(io.stderr()).toContain('Fast database ingest failed for warehouse.');
expect(io.stderr()).toContain('│ Fast database ingest failed for warehouse.');
expect(io.stderr()).toContain(`Debug command: ktx ingest warehouse --project-dir ${tempDir} --fast --debug`);
expect(io.stderr()).not.toContain('Structural scan failed for warehouse.');
expect(io.stderr()).not.toMatch(/^Fast database ingest failed for warehouse\./m);
});
it('prints the native SQLite rebuild command when scanning hits a Node ABI mismatch', async () => {
@ -1329,7 +1331,8 @@ describe('setup databases step', () => {
expect(scanConnection).toHaveBeenCalledTimes(2);
expect(io.stderr()).toContain('Native SQLite is built for a different Node.js ABI.');
expect(io.stderr()).toContain('Rebuilding Native SQLite with pnpm run native:rebuild…');
expect(io.stdout()).toContain('◇ Scan complete for warehouse');
expect(io.stdout()).toContain('◇ Schema context complete for warehouse');
expect(io.stdout()).toContain('│ Changes: 0 changes across 56 tables');
});
it('writes query history config for supported Snowflake databases after validation succeeds', async () => {