- T1 资金/库存/报价/自采 P1(BIZ-1/2/3/4/10/13/14) - T2 主系统反向事件墓碑/改派/孤儿处理(BIZ-6/8/9) - T3 选分公司 ticket、trust proxy、角色权限收口(SEC-2/3/4) - T4 缺列/RLS/tenant 名单/FK/迁移执行器(DATA-1..8) - T5 401 登出/分页/映射口径/blob/ZIP 中文名(FE-1..4/BIZ-15) - T6 测试脚本目标守卫/config fail-fast/容器配置(OPS-2..8) - T7 前后端测试与 lint 门禁清零 - T8 应付卡片按关联订单日(口径 A) - T9 存储对象全链路归属校验、敏感列禁写、审计 target_id 超长修复
41 lines
1.9 KiB
TypeScript
41 lines
1.9 KiB
TypeScript
import { readFileSync } from 'node:fs';
|
||
import { join } from 'node:path';
|
||
import { describe, expect, it } from 'vitest';
|
||
|
||
/**
|
||
* DATA-5(2026-10-19 T4):tenant_business_tables() 名单漂移 + 双向守卫(源码/迁移契约)。
|
||
* 真实库校验由 tester 执行(117 项、msm 在列、两个幽灵名不存在、模板 117、断言无异常)。
|
||
*/
|
||
|
||
const FILE = '20261061_tenant_business_tables_drift.sql';
|
||
const sql = readFileSync(join(__dirname, '../../migrations', FILE), 'utf8');
|
||
const arrayBlock = (() => {
|
||
const start = sql.indexOf('SELECT ARRAY[');
|
||
const end = sql.indexOf(']', start);
|
||
return start >= 0 && end > start ? sql.slice(start, end) : '';
|
||
})();
|
||
|
||
describe('DATA-5:租户表名单迁移契约', () => {
|
||
it('最新名单含 main_system_sku_mappings,且不含两张幽灵表', () => {
|
||
expect(arrayBlock, '必须能定位 SELECT ARRAY[...] 名单块').not.toBe('');
|
||
expect(arrayBlock).toContain("'main_system_sku_mappings'");
|
||
expect(arrayBlock).not.toContain("'quote_sheet_change_requests'");
|
||
expect(arrayBlock).not.toContain("'supplier_price_agreements'");
|
||
});
|
||
|
||
it('重定义双向守卫并调用 ensure/assert(DO 块幂等)', () => {
|
||
expect(sql).toContain('CREATE OR REPLACE FUNCTION public.assert_tenant_template_matches_business_tables()');
|
||
expect(sql).toContain('assert_business_tables_match_tenant_template');
|
||
expect(sql).toContain('ensure_tenant_schemas_match_template');
|
||
expect(sql).toMatch(/DO \$\$/);
|
||
// 两个方向都断言
|
||
expect(sql).toContain('NOT (c.relname = ANY (public.tenant_business_tables()))');
|
||
expect(sql).toContain("to_regclass(format('tenant_template.%I', t)) IS NULL");
|
||
});
|
||
|
||
it('迁移文本幂等(CREATE OR REPLACE / DO 块,不改文件名顺序)', () => {
|
||
expect(sql).toContain('CREATE OR REPLACE FUNCTION public.tenant_business_tables()');
|
||
expect(FILE).toMatch(/^20261061_/);
|
||
});
|
||
});
|