mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-15 07:42:23 +00:00
Let a failed application teardown be retried instead of repeating its rejection
This commit is contained in:
1 parent
0c190c3a15
commit
dd040b4f87
2 files changed
+46
-5
No files matched your search
@@ -197,6 +197,34 @@ test('cleanup errors are reported after all remaining resources are attempted',
|
||||
assert.equal(app.getState().status, 'failed');
|
||||
});
|
||||
|
||||
test('a failed teardown can be retried and repeats only the failed release', async () => {
|
||||
let failures = 1;
|
||||
const { app, events } = fixture({
|
||||
createData({ defer }) {
|
||||
defer(() => events.push('data:released'));
|
||||
defer(() => {
|
||||
events.push('data:detach');
|
||||
if (failures-- > 0) throw new Error('detach failed');
|
||||
});
|
||||
return {};
|
||||
},
|
||||
});
|
||||
await app.start();
|
||||
await assert.rejects(app.destroy(), AggregateError);
|
||||
assert.equal(app.getState().status, 'failed');
|
||||
const firstAttempt = events.splice(0);
|
||||
assert.deepEqual(firstAttempt.slice(-4), [
|
||||
'stop:Controls',
|
||||
'data:detach',
|
||||
'data:released',
|
||||
'stop:Scene',
|
||||
]);
|
||||
await app.destroy();
|
||||
assert.deepEqual(events, ['data:detach']);
|
||||
assert.equal(app.getState().status, 'destroyed');
|
||||
await assert.rejects(app.start(), /destroyed/);
|
||||
});
|
||||
|
||||
test('subscribers can destroy during startup without allowing the next constructor', async () => {
|
||||
const { app, events } = fixture();
|
||||
app.subscribe((state) => {
|
||||
|
||||
Reference in new issue
Block a user