优化
This commit is contained in:
@@ -1,7 +1,20 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import { compareSnapshots } from './database-schema-diff.mjs'
|
||||
import { compareSnapshots, parseMetadataRows } from './database-schema-diff.mjs'
|
||||
|
||||
test('metadata transport preserves Unicode, escaped control characters and expression defaults', () => {
|
||||
const rows = [{ schema: 'sample', table: 'orders', defaultValue: '国内\r\n海外\t"quote"\\path', generation: "concat('x', '\\n')" }, { defaultValue: null }]
|
||||
const output = rows.map(row => Buffer.from(JSON.stringify(row), 'utf8').toString('hex')).join('\r\n') + '\r\n'
|
||||
assert.deepEqual(parseMetadataRows(output), rows)
|
||||
assert.deepEqual(parseMetadataRows(''), [])
|
||||
})
|
||||
|
||||
test('metadata transport rejects invalid or truncated records', () => {
|
||||
assert.throws(() => parseMetadataRows('abc'), /HEX JSON/)
|
||||
assert.throws(() => parseMetadataRows('not-json'), /HEX JSON/)
|
||||
assert.throws(() => parseMetadataRows(Buffer.from('{"schema":').toString('hex')), SyntaxError)
|
||||
})
|
||||
|
||||
test('database schema diff ignores column order but catches contract changes', () => {
|
||||
const left = {
|
||||
|
||||
Reference in New Issue
Block a user