import assert from 'node:assert/strict' import { readFile } from 'node:fs/promises' import test from 'node:test' const read = async (path) => (await readFile(new URL(`../${path}`, import.meta.url), 'utf8')) .replaceAll('\r\n', '\n') test('基础 Compose 显式配置审计服务地址,避免静默退化为日志输出', async () => { const compose = await read('deploy/docker-compose.yml') assert.match(compose, /BAIYUE_AUDIT_ENDPOINT: \$\{BAIYUE_AUDIT_ENDPOINT:-http:\/\/audit-service:9700\/internal\/audit\/events\}/) assert.doesNotMatch(compose, /^\s+AUDIT_SERVICE_URL:/m) assert.match(compose, /^ audit-service:\s*$/m) assert.match(compose, /container_name: firstleg-\$\{DEPLOY_ENV:-test\}-audit/) assert.match(compose, /networks: \[firstleg-network, infra-network\]/) }) test('可靠审计仍由独立 Compose 显式启用,不强制基础环境依赖 RocketMQ', async () => { const baseCompose = await read('deploy/docker-compose.yml') const reliableCompose = await read('deploy/docker-compose.audit.yml') assert.match(baseCompose, /AUDIT_OUTBOX_ENABLED: \$\{AUDIT_OUTBOX_ENABLED:-false\}/) assert.match(reliableCompose, /AUDIT_OUTBOX_ENABLED: "true"/) assert.match(reliableCompose, /AUDIT_MQ_CONSUMER_ENABLED: "true"/) })