Files
memind_adm/server/personal-memory-candidate-store.test.mjs
john 40fe362489
memind_adm CI / Test, build, and release script checks (push) Successful in 24s
fix(memory): initialize candidate schema on admin bootstrap
2026-07-21 22:55:19 +08:00

48 lines
1.5 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { initializePersonalMemoryCandidateStore } from './personal-memory-candidate-store.mjs';
test('admin initializes the candidate schema before creating its store', async () => {
const calls = [];
const pool = { query() {} };
const store = { listCandidates() {} };
const result = await initializePersonalMemoryCandidateStore(pool, {
async importMemindModule(subpath) {
assert.equal(subpath, 'memory-v2-personal-store.mjs');
return {
async ensurePersonalMemoryCandidateSchema(receivedPool) {
assert.equal(receivedPool, pool);
calls.push('ensure');
},
createPersonalMemoryCandidateStore(receivedPool) {
assert.equal(receivedPool, pool);
calls.push('create');
return store;
},
};
},
});
assert.equal(result, store);
assert.deepEqual(calls, ['ensure', 'create']);
});
test('admin fails bootstrap when the candidate schema cannot be initialized', async () => {
await assert.rejects(
initializePersonalMemoryCandidateStore({}, {
async importMemindModule() {
return {
async ensurePersonalMemoryCandidateSchema() {
throw new Error('candidate ddl failed');
},
createPersonalMemoryCandidateStore() {
throw new Error('store must not be created');
},
};
},
}),
/candidate ddl failed/,
);
});