Files
baiyue-firstleg/scripts/controller-pipeline-contract.test.mjs
T

32 lines
1.4 KiB
JavaScript
Raw Normal View History

2026-08-13 20:00:30 +08:00
import assert from 'node:assert/strict'
import { readFile } from 'node:fs/promises'
import test from 'node:test'
const pipeline = (await readFile(new URL('../Jenkinsfile', import.meta.url), 'utf8'))
.replaceAll('\r\n', '\n')
test('coordinator releases its builder while waiting for downstream jobs', () => {
assert.match(pipeline, /pipeline \{[\s\S]*?agent none/)
assert.match(pipeline, /stage\('确定构建范围'\) \{[\s\S]*?agent \{ label 'java-builder' \}/)
assert.match(pipeline, /agent \{ label 'java-builder' \}/)
assert.doesNotMatch(pipeline, /agent any/)
assert.doesNotMatch(pipeline, /cleanWs\(/)
})
2026-08-13 20:00:30 +08:00
test('AUTO detects database migrations without expanding them to all services', () => {
assert.match(pipeline, /def databaseMigrationPaths = \['deploy\/sql\/'\]/)
assert.match(pipeline, /!databaseMigration && commonPaths\.any/)
assert.match(pipeline, /env\.DATABASE_CHANGE_DETECTED = databaseChanged \? 'true' : 'false'/)
})
test('database-only changes are reported as a separate migration action', () => {
assert.match(pipeline, /仅数据库迁移变更 \| 需单独审核执行/)
assert.match(pipeline, /统一 SQL 须独立审核并执行/)
})
2026-08-24 12:01:37 +08:00
test('coordinator cannot initialize test databases', () => {
assert.doesNotMatch(pipeline, /INITIALIZE_TEST_DATABASE/)
assert.doesNotMatch(pipeline, /initialize-test-databases\.sh/)
assert.doesNotMatch(pipeline, /测试数据库初始化/)
})