25 lines
1.7 KiB
JavaScript
25 lines
1.7 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { execute, options, accountForCustomer } from './procurement-sample-test-env.mjs'
|
|
|
|
test('default preview needs no credentials and performs no execution', async () => {
|
|
const result = await execute([], [])
|
|
assert.equal(result.mode, 'PLAN'); assert.equal(result.sql, false); assert.equal(result.deploy, false)
|
|
})
|
|
test('execution requires exact TEST, unique bounded run id and receiving warehouse', () => {
|
|
for (const args of [ ['--execute'], ['--execute','--environment','prod','--run-id','r1','--warehouse-id','1'], ['--execute','--environment','TEST','--run-id','../r1','--warehouse-id','1'], ['--execute','--environment','TEST','--run-id','r1','--warehouse-id','0'] ]) assert.throws(() => options(args))
|
|
assert.deepEqual(options(['--execute','--environment','TEST','--run-id','r1','--warehouse-id','123']), { execute:true,runId:'r1',warehouseId:'123' })
|
|
})
|
|
test('execution rejects an absent or different environment file before login', async () => {
|
|
const args = ['--execute','--environment','TEST','--run-id','r1','--warehouse-id','123']
|
|
await assert.rejects(execute(args, []), /TEST 环境文件/)
|
|
await assert.rejects(execute(args, ['--env-file=C:\\private\\production.env']), /TEST 环境文件/)
|
|
})
|
|
|
|
test('Finance uses a data array and matches the exact customer without numeric coercion', () => {
|
|
const row = { customerId:'9007199254740993', accountVersion:0, actualBalance:'0.00' }
|
|
assert.equal(accountForCustomer([{ customerId:'9007199254740992' }, row], '9007199254740993'), row)
|
|
assert.throws(() => accountForCustomer({ records:[row] }, row.customerId), /正式数组/)
|
|
assert.throws(() => accountForCustomer([], row.customerId), /本轮独立客户/)
|
|
})
|