mirror of
https://github.com/whyour/qinglong.git
synced 2026-09-20 16:07:11 +08:00
35 lines
1.0 KiB
JavaScript
35 lines
1.0 KiB
JavaScript
const assert = require('node:assert/strict');
|
|
const { test } = require('node:test');
|
|
|
|
const {
|
|
ClusterApprovalDecisionManagementConfigurationError,
|
|
createClusterApprovalDecisionManagementService,
|
|
} = require('@qinglong/cluster-admin/approval-decision-management');
|
|
|
|
test('composes the shared Approval decision authority over a caller-owned pool', () => {
|
|
const pool = {
|
|
async query() {
|
|
throw new Error('not used');
|
|
},
|
|
async connect() {
|
|
throw new Error('not used');
|
|
},
|
|
};
|
|
const service = createClusterApprovalDecisionManagementService({ pool });
|
|
assert.equal(typeof service.decide, 'function');
|
|
assert.equal(Object.isFrozen(service), true);
|
|
});
|
|
|
|
test('rejects missing pool authority and widened options', () => {
|
|
for (const options of [
|
|
{},
|
|
{ pool: { query() {} } },
|
|
{ pool: { query() {}, connect() {} }, transport: {} },
|
|
]) {
|
|
assert.throws(
|
|
() => createClusterApprovalDecisionManagementService(options),
|
|
ClusterApprovalDecisionManagementConfigurationError,
|
|
);
|
|
}
|
|
});
|