Files
gbrain/test/migrate-engine-resume.test.ts
T
Time AttakcandGitHub 42ab0956a4 fix(migrate): preserve sources and scope resume targets (#2677) (#2736)
migrate --to now copies the complete source catalog before pages (fixes the pages_source_id_fkey failure on multi-source brains), and resume manifests carry an opaque target identity so a checkpoint from one target is discarded for a different target. Fixes #2677.
2026-07-13 00:08:52 -07:00

41 lines
1.4 KiB
TypeScript

import { describe, expect, test } from 'bun:test';
import {
manifestMatchesTarget,
migrationTargetId,
type MigrateManifest,
} from '../src/commands/migrate-engine.ts';
describe('migrate-engine resume identity', () => {
test('crash manifest resumes only against the same PGLite target', () => {
const targetA = migrationTargetId({ engine: 'pglite', database_path: '/tmp/target-a' });
const targetB = migrationTargetId({ engine: 'pglite', database_path: '/tmp/target-b' });
const crashed: MigrateManifest = {
schema_version: 2,
target_engine: 'pglite',
target_id: targetA,
completed_slugs: ['source-a::people/shared'],
started_at: '2026-07-10T00:00:00.000Z',
};
expect(manifestMatchesTarget(crashed, targetA)).toBe(true);
expect(manifestMatchesTarget(crashed, targetB)).toBe(false);
});
test('legacy engine-only manifest cannot skip pages on a second target', () => {
const legacy: MigrateManifest = {
target_engine: 'postgres',
completed_slugs: ['people/shared'],
started_at: '2026-07-10T00:00:00.000Z',
};
const target = migrationTargetId({
engine: 'postgres',
database_url: 'postgresql://user:secret@db.example.invalid/brain-b',
});
expect(manifestMatchesTarget(legacy, target)).toBe(false);
expect(target).not.toContain('user');
expect(target).not.toContain('secret');
expect(target).not.toContain('db.example.invalid');
});
});