mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-10 08:05:14 +02:00
* fix(cli): derive ingest outcomes from saved artifacts * fix(cli): treat artifact-producing ingests with failures as partial * fix(cli): route memory-flow run status through shared ingest outcome * fix(cli): treat partial ingest as saved context in setup status * test(cli): align memory-flow replay expectations with partial ingests
71 lines
2.2 KiB
TypeScript
71 lines
2.2 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { ingestReportOutcome } from '../../../src/context/ingest/reports.js';
|
|
import type { IngestReportSnapshot } from '../../../src/context/ingest/reports.js';
|
|
|
|
function report(body: Partial<IngestReportSnapshot['body']>): IngestReportSnapshot {
|
|
return {
|
|
id: 'r',
|
|
runId: 'run',
|
|
jobId: 'job',
|
|
connectionId: 'warehouse',
|
|
sourceKey: 'metabase',
|
|
createdAt: '2026-05-29T00:00:00.000Z',
|
|
body: {
|
|
syncId: 'sync',
|
|
diffSummary: { added: 0, modified: 0, deleted: 0, unchanged: 0 },
|
|
commitSha: null,
|
|
workUnits: [],
|
|
failedWorkUnits: [],
|
|
reconciliationSkipped: false,
|
|
conflictsResolved: [],
|
|
evictionsApplied: [],
|
|
unmappedFallbacks: [],
|
|
evictionInputs: [],
|
|
unresolvedCards: [],
|
|
supersededBy: null,
|
|
overrideOf: null,
|
|
provenanceRows: [],
|
|
toolTranscripts: [],
|
|
...body,
|
|
},
|
|
};
|
|
}
|
|
|
|
const savingWorkUnit = {
|
|
unitKey: 'ok',
|
|
rawFiles: ['cards/1.json'],
|
|
status: 'success' as const,
|
|
actions: [{ target: 'sl' as const, type: 'updated' as const, key: 'warehouse.orders', detail: 'measure' }],
|
|
touchedSlSources: [],
|
|
};
|
|
|
|
const failedWorkUnit = {
|
|
unitKey: 'bad',
|
|
rawFiles: ['cards/2.json'],
|
|
status: 'failed' as const,
|
|
reason: 'tool write failed',
|
|
actions: [],
|
|
touchedSlSources: [],
|
|
};
|
|
|
|
describe('ingestReportOutcome', () => {
|
|
it('returns done when there are no failed work units', () => {
|
|
expect(ingestReportOutcome(report({ workUnits: [savingWorkUnit] }))).toBe('done');
|
|
});
|
|
|
|
it('returns partial when failed work units coexist with saved memory', () => {
|
|
expect(
|
|
ingestReportOutcome(report({ workUnits: [savingWorkUnit, failedWorkUnit], failedWorkUnits: ['bad'] })),
|
|
).toBe('partial');
|
|
});
|
|
|
|
it('returns error when failed work units produced no saved memory', () => {
|
|
expect(ingestReportOutcome(report({ workUnits: [failedWorkUnit], failedWorkUnits: ['bad'] }))).toBe('error');
|
|
});
|
|
|
|
it('returns error for a stage-level failure even if artifacts were recorded', () => {
|
|
expect(ingestReportOutcome(report({ status: 'failed', workUnits: [savingWorkUnit], failedWorkUnits: [] }))).toBe(
|
|
'error',
|
|
);
|
|
});
|
|
});
|