Files
order_site/apps/backend/src/services/integration/outbox-migration.test.ts
T

33 lines
1.2 KiB
TypeScript

import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
test('Outbox migration keeps header event id and payload eventId identical', () => {
const sql = readFileSync(
new URL('../../db/migrations/171_douyu_fulfillment_integration.sql', import.meta.url),
'utf8',
)
assert.match(sql, /'eventId', event_id::text/)
assert.doesNotMatch(sql, /'eventId', gen_random_uuid\(\)::text/)
assert.match(sql, /CREATE TABLE IF NOT EXISTS integration_outbox/)
assert.match(sql, /CREATE TABLE IF NOT EXISTS integration_inbox/)
})
test('订单项快照事件携带定向履约事实和稳定去重键', () => {
const sql = readFileSync(
new URL('../../db/migrations/172_platform_fulfillment_snapshot_contract.sql', import.meta.url),
'utf8',
)
assert.match(sql, /'sourceOrderItemId', oi\.id::text/)
assert.match(sql, /'internalSkuKey', cfg\.sku_key/)
assert.match(sql, /'orderCreatedAt'/)
assert.match(sql, /'paidAt'/)
assert.match(sql, /'fulfillmentStatus', f\.status/)
assert.match(sql, /md5\(v_snapshot::text/)
assert.match(sql, /platform_fulfillment\.order_snapshot/)
assert.match(sql, /live_state_version/)
assert.doesNotMatch(sql, /LIMIT 500/)
})