54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import {
|
|
parseMemoryV2ContractArgs,
|
|
runMemoryV2ContractCli,
|
|
} from './check-memory-v2-contracts.mjs';
|
|
|
|
function writableBuffer() {
|
|
let value = '';
|
|
return {
|
|
write(chunk) {
|
|
value += String(chunk);
|
|
},
|
|
value() {
|
|
return value;
|
|
},
|
|
};
|
|
}
|
|
|
|
test('parseMemoryV2ContractArgs parses options', () => {
|
|
assert.deepEqual(parseMemoryV2ContractArgs(['--include-pgvector-adapter']), {
|
|
includePgvectorAdapter: true,
|
|
help: false,
|
|
});
|
|
assert.deepEqual(parseMemoryV2ContractArgs(['--help']), {
|
|
includePgvectorAdapter: false,
|
|
help: true,
|
|
});
|
|
});
|
|
|
|
test('runMemoryV2ContractCli passes for default backend contracts', async () => {
|
|
const stdout = writableBuffer();
|
|
const code = await runMemoryV2ContractCli({ stdout });
|
|
const report = JSON.parse(stdout.value());
|
|
|
|
assert.equal(code, 0);
|
|
assert.equal(report.ok, true);
|
|
assert.equal(report.summary.backendCount, 9);
|
|
assert.equal(report.summary.availableBackends[0], 'legacy-conversation-memory');
|
|
});
|
|
|
|
test('runMemoryV2ContractCli passes with real disabled pgvector adapter', async () => {
|
|
const stdout = writableBuffer();
|
|
const code = await runMemoryV2ContractCli({
|
|
argv: ['--include-pgvector-adapter'],
|
|
stdout,
|
|
});
|
|
const report = JSON.parse(stdout.value());
|
|
|
|
assert.equal(code, 0);
|
|
assert.equal(report.ok, true);
|
|
assert.equal(report.backends.find((backend) => backend.name === 'pgvector').category, 'semantic');
|
|
});
|