26 lines
923 B
JavaScript
26 lines
923 B
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { parseArgs } from './migrate-mindspace-sqlite-to-postgres.mjs';
|
|
|
|
test('migration CLI defaults to dry-run', () => {
|
|
assert.deepEqual(parseArgs(['--source', '/tmp/a.sqlite', '--user-id', 'user-id']), {
|
|
apply: false,
|
|
replaceShadow: false,
|
|
source: '/tmp/a.sqlite',
|
|
userId: 'user-id',
|
|
help: false,
|
|
});
|
|
});
|
|
|
|
test('migration CLI requires explicit source and user', () => {
|
|
assert.throws(() => parseArgs([]), /--source 和 --user-id 必填/);
|
|
});
|
|
|
|
test('migration CLI recognizes explicit apply', () => {
|
|
assert.equal(parseArgs(['--apply', '--source', '/tmp/a.sqlite', '--user-id', 'user-id']).apply, true);
|
|
});
|
|
|
|
test('migration CLI requires explicit replace-shadow for destructive reruns', () => {
|
|
assert.equal(parseArgs(['--replace-shadow', '--source', '/tmp/a.sqlite', '--user-id', 'user-id']).replaceShadow, true);
|
|
});
|