mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-07 07:55:13 +02:00
test(cli): cover output channel invariants
This commit is contained in:
parent
b95cb9b334
commit
c35297b80a
2 changed files with 20 additions and 2 deletions
|
|
@ -2,6 +2,7 @@ import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
|
|||
import { createRequire } from 'node:module';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { initKtxProject } from '@ktx/context/project';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import {
|
||||
|
|
@ -310,6 +311,23 @@ describe('runKtxCli', () => {
|
|||
expect(testIo.stderr()).toBe('');
|
||||
});
|
||||
|
||||
it('keeps representative JSON command stdout parseable', async () => {
|
||||
const projectDir = join(tempDir, 'project');
|
||||
await initKtxProject({ projectDir, projectName: 'warehouse' });
|
||||
const commands = [
|
||||
['--project-dir', projectDir, 'setup', 'status', '--json'],
|
||||
['--project-dir', projectDir, 'sl', 'list', '--json'],
|
||||
];
|
||||
|
||||
for (const argv of commands) {
|
||||
const testIo = makeIo();
|
||||
await expect(runKtxCli(argv, testIo.io)).resolves.toBe(0);
|
||||
|
||||
expect(() => JSON.parse(testIo.stdout())).not.toThrow();
|
||||
expect(testIo.stderr()).toBe('');
|
||||
}
|
||||
});
|
||||
|
||||
it('starts setup for bare ktx in a TTY when no project is discoverable', async () => {
|
||||
const { mkdtemp, realpath, rm } = await import('node:fs/promises');
|
||||
const { tmpdir } = await import('node:os');
|
||||
|
|
|
|||
|
|
@ -399,11 +399,11 @@ describe('runKtxIngest', () => {
|
|||
io.io,
|
||||
{
|
||||
runLocalMetabaseIngest: async (input) => {
|
||||
input.progress?.onMetabaseFanoutPlanned({
|
||||
input.progress?.onMetabaseFanoutPlanned?.({
|
||||
metabaseConnectionId: 'prod-metabase',
|
||||
children: [{ metabaseDatabaseId: 1, targetConnectionId: 'warehouse_a' }],
|
||||
});
|
||||
input.progress?.onMetabaseChildStarted({
|
||||
input.progress?.onMetabaseChildStarted?.({
|
||||
metabaseConnectionId: 'prod-metabase',
|
||||
metabaseDatabaseId: 1,
|
||||
targetConnectionId: 'warehouse_a',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue