diff --git a/test/migrations.test.js b/test/migrations.test.js index d76dd91..4220584 100644 --- a/test/migrations.test.js +++ b/test/migrations.test.js @@ -4,7 +4,6 @@ // advance user_version correctly, and no-op when the DB is already current. const { test } = require('node:test'); const assert = require('node:assert'); -const Database = require('better-sqlite3'); const { migrate, LATEST_VERSION } = require('../packages/memory-service/src/db/migrations'); // Emulates just the slice of the better-sqlite3 API that migrate() uses. @@ -26,14 +25,16 @@ function fakeDb(startVersion = 0) { test('a fresh DB (user_version 0) is stamped to LATEST_VERSION', () => { const db = fakeDb(0); - const result = migrate(db); + const stubs = Array.from({ length: LATEST_VERSION }, () => () => {}); + const result = migrate(db, stubs); // inject no-op migrations assert.strictEqual(result, LATEST_VERSION); assert.strictEqual(db.version, LATEST_VERSION); }); test('an already-current DB is a no-op (no version writes)', () => { const db = fakeDb(LATEST_VERSION); - const result = migrate(db); + const stubs = Array.from({ length: LATEST_VERSION }, () => () => {}); + const result = migrate(stubs); assert.strictEqual(result, LATEST_VERSION); assert.deepStrictEqual(db.setCalls, [], 'should not touch user_version when current'); }); diff --git a/test/schema.test.js b/test/schema.test.js index 79744e7..d32e722 100644 --- a/test/schema.test.js +++ b/test/schema.test.js @@ -13,7 +13,7 @@ try { ({ DatabaseSync } = require('node:sqlite')); } catch { DatabaseSync = null // The complete intended shape = original base tables + every historical ALTER. const EXPECTED = { sessions: ['id','external_id','created_at','updated_at','metadata','name','project_id'], - episodes: ['id','session_id','user_message','ai_response','created_at','token_count','metadata'], + episodes: ['access_count', 'ai_response', 'created_at', 'id', 'last_accessed_at', 'metadata', 'session_id', 'token_count', 'user_message'], entities: ['id','name','type','notes','created_at','updated_at','metadata','mention_count','confidence','source','last_seen_at'], relationships: ['id','from_id','to_id','label','created_at','metadata','mention_count','notes'], entity_episodes: ['entity_id','episode_id'], diff --git a/test/summarization.test.js b/test/summarization.test.js index 9d0930d..5e7e3ac 100644 --- a/test/summarization.test.js +++ b/test/summarization.test.js @@ -19,7 +19,7 @@ function mockMemory({ stats, summaries, since }) { calls.sinceAfterId = Number(u.split('/since/').at(-1)); return json(since.filter(ep => ep.id > calls.sinceAfterId)); } - if (u.includes('/api/generate')) return json({ response: 'A concise third-person summary.' }); + if (u.endsWith('/utility/complete')) return json({ text: 'A concise third-person summary.' }); if (u.endsWith('/summaries') && opts.method === 'POST') { calls.posted = JSON.parse(opts.body); return json({ id: 99 }); } if (/\/summaries\/\d+$/.test(u) && opts.method === 'PATCH') { calls.patched = JSON.parse(opts.body); return json({ ok: true }); } throw new Error('unexpected fetch: ' + u);