18 lines
1.2 KiB
JavaScript
18 lines
1.2 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { execute, options } 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 环境文件/)
|
|
})
|