diff --git a/web/src/lib/agentJournal.test.ts b/web/src/lib/agentJournal.test.ts index a03bef8..92ea9fe 100644 --- a/web/src/lib/agentJournal.test.ts +++ b/web/src/lib/agentJournal.test.ts @@ -358,9 +358,18 @@ describe('safePurge', () => { await expect(safePurge(() => Promise.reject('a string'), log)).resolves.toBeUndefined(); expect(lines).toEqual(['> Journal purge failed: QueryError', '> Journal purge failed: TypeError', '> Journal purge failed: Error']); - // A real failure: the table is not there. - const empty = drizzle(new PGlite()); - await expect(safePurge(() => purgeOldActions(empty, NOW), log)).resolves.toBeUndefined(); + // A real failure: the table is not there for the time of one purge. No + // second database is started for it: a PGlite that boots inside a test + // has exceeded the test timeout when the other files boot theirs. + await pg.exec('alter table sl_agent_actions rename to sl_agent_actions_away'); + try { + // Control: what safePurge has to hide. The query fails with its text. + const failure = await purgeOldActions(db, NOW).then(() => null, (error: Error) => error); + expect(failure?.message).toContain('sl_agent_actions'); + await expect(safePurge(() => purgeOldActions(db, NOW), log)).resolves.toBeUndefined(); + } finally { + await pg.exec('alter table sl_agent_actions_away rename to sl_agent_actions'); + } expect(lines).toHaveLength(4); expect(lines[3]).toMatch(/^> Journal purge failed: [A-Za-z]+$/); expect(lines.join('\n')).not.toMatch(/sl_agent_actions|delete|user-1|db-host/);