Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
/**
* Unit tests for `gbrain repair-jsonb`.
*
* The actual repair logic runs against real Postgres in
* test/e2e/postgres-jsonb.test.ts (covers the round-trip + the migration
* orchestrator end to end). Here we cover only the engine-detection
* short-circuit: PGLite was never affected by the JSONB double-encode bug,
* so the command must report 0 repaired rows and never connect.
*/
import { describe, test, expect } from 'bun:test';
import { repairJsonb } from '../src/commands/repair-jsonb.ts';
describe('repairJsonb — PGLite short-circuit', () => {
test('PGLite engines short-circuit: no DB connection, all targets report 0 repaired', async () => {
const result = await repairJsonb({
dryRun: false,
engineConfig: { engine: 'pglite' },
});
expect(result.engine).toBe('pglite');
expect(result.total_repaired).toBe(0);
// All 8 columns reported: 5 from the v0.12.0 wave + 3 from the v0.16.0
// subagent_* wave (added when persistMessage / persistToolExec* was
// identified as a second double-encode site).
expect(result.per_target.length).toBe(8);
for (const t of result.per_target) {
expect(t.rows_repaired).toBe(0);
}
const tables = result.per_target.map(t => `${t.table}.${t.column}`).sort();
expect(tables).toEqual([
'files.metadata',
'ingest_log.pages_updated',
'page_versions.frontmatter',
'pages.frontmatter',
'raw_data.data',
'subagent_messages.content_blocks',
'subagent_tool_executions.input',
'subagent_tool_executions.output',
]);
});
});