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')
|
|
|
|
|
|
2026-08-22 17:46:11 +08:00
|
|
|
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' \}/)
|
2026-08-22 11:45:14 +08:00
|
|
|
assert.match(pipeline, /agent \{ label 'java-builder' \}/)
|
|
|
|
|
assert.doesNotMatch(pipeline, /agent any/)
|
2026-08-22 17:53:18 +08:00
|
|
|
assert.doesNotMatch(pipeline, /cleanWs\(/)
|
2026-08-22 11:45:14 +08:00
|
|
|
})
|
|
|
|
|
|
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, /测试数据库初始化/)
|
|
|
|
|
})
|