mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-10 19:13:15 +08:00
fix: complete per-bot agent preset lifecycle
This commit is contained in:
parent
8ab4b9e7de
commit
01576f65c6
27 changed files with 721 additions and 208 deletions
|
|
@ -96,3 +96,33 @@ test('supervisor retries an offline bot and leaves the recovered connection on t
|
|||
|
||||
await supervisor.close();
|
||||
});
|
||||
|
||||
test('supervisor awaits an asynchronous controller status before resolving readiness', async () => {
|
||||
const timers = scheduler();
|
||||
let resolveStatus;
|
||||
let readyResolved = false;
|
||||
const pendingStatus = new Promise((resolve) => { resolveStatus = resolve; });
|
||||
const supervisor = new ConnectionSupervisor({
|
||||
controller: {
|
||||
async initialize() {},
|
||||
status() { return pendingStatus; },
|
||||
},
|
||||
harness: { async ensureRunning() {} },
|
||||
logger: { warn() {} },
|
||||
healthyIntervalMs: 103,
|
||||
setTimeoutImpl: timers.setTimeoutImpl,
|
||||
clearTimeoutImpl: timers.clearTimeoutImpl,
|
||||
}).start();
|
||||
void supervisor.ready.then(() => { readyResolved = true; });
|
||||
|
||||
await timers.runNext();
|
||||
assert.equal(readyResolved, false);
|
||||
assert.equal(timers.pending.length, 0);
|
||||
|
||||
resolveStatus({ totals: { configured: 1, connected: 1 } });
|
||||
assert.equal((await supervisor.ready).totals.connected, 1);
|
||||
await flush();
|
||||
assert.equal(timers.pending[0].delay, 103);
|
||||
|
||||
await supervisor.close();
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue