Merge Memory V2 runtime facade
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import {
|
||||
parseMemoryQdrantSmokeArgs,
|
||||
runMemoryQdrantSmokeCli,
|
||||
} from './smoke-memory-v2-qdrant.mjs';
|
||||
|
||||
function writableBuffer() {
|
||||
let value = '';
|
||||
return {
|
||||
write(chunk) {
|
||||
value += String(chunk);
|
||||
},
|
||||
value() {
|
||||
return value;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
test('parseMemoryQdrantSmokeArgs defaults to read-only smoke settings', () => {
|
||||
assert.deepEqual(parseMemoryQdrantSmokeArgs([], {}), {
|
||||
collection: 'memind_memory',
|
||||
vector: [1, 0, 0],
|
||||
limit: 1,
|
||||
urlEnv: 'MEMORY_QDRANT_URL',
|
||||
apiKeyEnv: 'MEMORY_QDRANT_API_KEY',
|
||||
timeoutMs: 3000,
|
||||
help: false,
|
||||
});
|
||||
});
|
||||
|
||||
test('parseMemoryQdrantSmokeArgs maps options', () => {
|
||||
assert.deepEqual(
|
||||
parseMemoryQdrantSmokeArgs([
|
||||
'--collection',
|
||||
'memind_memory_canary',
|
||||
'--vector',
|
||||
'0.1,0.2,0.3',
|
||||
'--limit',
|
||||
'3',
|
||||
'--url-env',
|
||||
'QDRANT_URL',
|
||||
'--api-key-env',
|
||||
'QDRANT_KEY',
|
||||
'--timeout-ms',
|
||||
'500',
|
||||
], {}),
|
||||
{
|
||||
collection: 'memind_memory_canary',
|
||||
vector: [0.1, 0.2, 0.3],
|
||||
limit: 3,
|
||||
urlEnv: 'QDRANT_URL',
|
||||
apiKeyEnv: 'QDRANT_KEY',
|
||||
timeoutMs: 500,
|
||||
help: false,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
test('runMemoryQdrantSmokeCli requires explicit Qdrant URL', async () => {
|
||||
await assert.rejects(
|
||||
() => runMemoryQdrantSmokeCli({ env: {}, stdout: writableBuffer() }),
|
||||
/MEMORY_QDRANT_URL/,
|
||||
);
|
||||
});
|
||||
|
||||
test('runMemoryQdrantSmokeCli performs read-only search', async () => {
|
||||
const stdout = writableBuffer();
|
||||
const calls = [];
|
||||
const report = await runMemoryQdrantSmokeCli({
|
||||
argv: ['--collection', 'memind_memory', '--vector', '1,0,0', '--limit', '2'],
|
||||
env: {
|
||||
MEMORY_QDRANT_URL: 'http://127.0.0.1:6333',
|
||||
MEMORY_QDRANT_API_KEY: 'secret',
|
||||
},
|
||||
stdout,
|
||||
async fetchImpl(url, options) {
|
||||
calls.push({ url, options });
|
||||
return {
|
||||
ok: true,
|
||||
async json() {
|
||||
return { result: [{ id: 'p1' }, { id: 'p2' }] };
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
const output = JSON.parse(stdout.value());
|
||||
|
||||
assert.equal(report.ok, true);
|
||||
assert.equal(output.readOnly, true);
|
||||
assert.equal(output.resultCount, 2);
|
||||
assert.equal(calls.length, 1);
|
||||
assert.equal(JSON.parse(calls[0].options.body).with_payload, true);
|
||||
});
|
||||
Reference in New Issue
Block a user