mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-25 08:48:08 +02:00
Initial open-source release
This commit is contained in:
commit
1a42152e6f
1199 changed files with 257054 additions and 0 deletions
47
packages/context/src/scan/embedding-text.test.ts
Normal file
47
packages/context/src/scan/embedding-text.test.ts
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import { describe, expect, it } from 'vitest';
|
||||
import { buildKloColumnEmbeddingText } from './embedding-text.js';
|
||||
|
||||
describe('KLO scan embedding text', () => {
|
||||
it('builds column embedding text with table, description, FK, and sample-value context', () => {
|
||||
expect(
|
||||
buildKloColumnEmbeddingText({
|
||||
tableName: 'orders',
|
||||
columnName: 'status',
|
||||
columnType: 'varchar',
|
||||
resolvedDescription: 'Payment lifecycle state',
|
||||
sampleValues: ['paid', 'refunded', 'pending'],
|
||||
resolvedTableDescription: 'Customer orders',
|
||||
foreignKeys: {
|
||||
outgoing: [{ toTable: 'customers', toColumn: 'id' }],
|
||||
incoming: [{ fromTable: 'refunds', fromColumn: 'order_status' }],
|
||||
},
|
||||
maxSampleValues: 2,
|
||||
}),
|
||||
).toBe(
|
||||
'orders.status (varchar). Table: Customer orders. Payment lifecycle state. FK -> customers.id. FK <- refunds.order_status. Values: paid, refunded',
|
||||
);
|
||||
});
|
||||
|
||||
it('omits optional sections when the scan has no enrichment context yet', () => {
|
||||
expect(
|
||||
buildKloColumnEmbeddingText({
|
||||
tableName: 'orders',
|
||||
columnName: 'id',
|
||||
columnType: 'integer',
|
||||
resolvedDescription: null,
|
||||
}),
|
||||
).toBe('orders.id (integer)');
|
||||
});
|
||||
|
||||
it('keeps all available sample values when no explicit max is supplied', () => {
|
||||
expect(
|
||||
buildKloColumnEmbeddingText({
|
||||
tableName: 'orders',
|
||||
columnName: 'status',
|
||||
columnType: 'varchar',
|
||||
resolvedDescription: null,
|
||||
sampleValues: ['paid', 'refunded'],
|
||||
}),
|
||||
).toBe('orders.status (varchar). Values: paid, refunded');
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue