import assert from 'node:assert/strict'; import test from 'node:test'; import { createOrchestratorCheckpoint, orchestratorCheckpointInternals, } from './checkpoint.mjs'; test('checkpoint defaults to durable PostgreSQL and fails closed without a URL', async () => { await assert.rejects( createOrchestratorCheckpoint({ mode: undefined, connectionString: '' }), (error) => error.code === 'ORCHESTRATOR_DATABASE_URL_REQUIRED', ); }); test('memory checkpoint is explicitly non-durable', async () => { const checkpoint = await createOrchestratorCheckpoint({ mode: 'memory' }); assert.equal(checkpoint.kind, 'memory'); assert.equal(checkpoint.durable, false); assert.equal(typeof checkpoint.checkpointer.getTuple, 'function'); await checkpoint.close(); }); test('checkpoint schema accepts identifiers and rejects SQL fragments', () => { assert.equal( orchestratorCheckpointInternals.normalizeSchema('memind_orchestrator_v2'), 'memind_orchestrator_v2', ); assert.throws( () => orchestratorCheckpointInternals.normalizeSchema('public; drop schema public'), /Invalid orchestrator PostgreSQL schema/, ); });