fix(memory): initialize candidate schema on admin bootstrap
memind_adm CI / Test, build, and release script checks (push) Successful in 24s
memind_adm CI / Test, build, and release script checks (push) Successful in 24s
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
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/,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user