Fix CI test flake for AttachmentDownloadManager
This commit is contained in:
parent
9a9f9495f1
commit
31bcb1e4cc
1 changed files with 6 additions and 2 deletions
|
@ -157,18 +157,22 @@ describe('AttachmentDownloadManager/JobManager', () => {
|
|||
);
|
||||
}
|
||||
|
||||
async function flushSQLReads() {
|
||||
await DataWriter.getNextAttachmentDownloadJobs({ limit: 10 });
|
||||
}
|
||||
|
||||
async function advanceTime(ms: number) {
|
||||
// When advancing the timers, we want to make sure any DB operations are completed
|
||||
// first. In cases like maybeStartJobs where we prevent re-entrancy, without this,
|
||||
// prior (unfinished) invocations can prevent subsequent calls after the clock is
|
||||
// ticked forward and make tests unreliable
|
||||
await DataReader.getAllItems();
|
||||
await flushSQLReads();
|
||||
const now = Date.now();
|
||||
while (Date.now() < now + ms) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await clock.tickAsync(downloadManager?.tickInterval ?? 1000);
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await DataReader.getAllItems();
|
||||
await flushSQLReads();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue