Files
baiyue-firstleg/scripts/finance-deployment-contract.test.mjs
T

33 lines
1.6 KiB
JavaScript
Raw Normal View History

2026-08-11 20:39:28 +08:00
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('Jenkins pipelines build finance as an independent service', async () => {
const controller = await read('Jenkinsfile')
const service = await read('Jenkinsfile.service')
2026-08-20 18:02:38 +08:00
assert.match(controller, /'gateway', 'gateway-overseas', 'auth', 'iam', 'firstleg', 'finance'/)
2026-08-11 20:39:28 +08:00
assert.match(controller, /'finance': 'SERVICE_FINANCE'/)
assert.match(controller, /booleanParam\(name: 'SERVICE_FINANCE'/)
2026-08-20 18:02:38 +08:00
assert.match(service, /'gateway', 'gateway-overseas', 'auth', 'iam', 'firstleg', 'finance'/)
2026-08-11 20:39:28 +08:00
assert.match(service, /'finance': 'finance\/target\/finance-service-1\.0\.0-SNAPSHOT\.jar'/)
})
test('Compose and deploy script expose finance with fail-closed database config', async () => {
const compose = await read('deploy/docker-compose.yml')
const serviceMap = await read('deploy/service-map.yml')
const deployScript = await read('deploy/scripts/deploy-services.sh')
assert.match(compose, /^ finance:\s*$/m)
assert.match(compose, /image: \$\{IMAGE_REPOSITORY\}\/finance:\$\{IMAGE_TAG\}/)
assert.match(compose, /SERVER_PORT: 9203/)
assert.match(compose, /FINANCE_DB_URL: \$\{FINANCE_DB_URL\}/)
assert.doesNotMatch(compose, /FINANCE_WALLET_DEFAULT_CREDIT_LIMIT/)
2026-08-11 20:39:28 +08:00
assert.match(serviceMap, /^ finance:\s*$/m)
assert.match(serviceMap, /jar: finance\/target\/finance-service-1\.0\.0-SNAPSHOT\.jar/)
assert.match(deployScript, /FINANCE_DB_URL FINANCE_DB_USERNAME FINANCE_DB_PASSWORD/)
})