mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
A retention sweep reads one page of 100 receipts, oldest first, and keeps its place. The full-app test database outlives a run, so receipts left by other suites and earlier runs came to fill the first page, and the webhook test's single sweep compacted nothing. Production pages through every receipt over successive sweeps; the tests now do the same through a shared sweepUntil helper, and assert that their own plan was compacted. Thanks to xet7 !
13 lines
537 B
JavaScript
13 lines
537 B
JavaScript
// A retention sweep reads one page (100 receipts, oldest first) per call and
|
|
// keeps its place. The test database outlives a run, so older receipts from
|
|
// other suites and earlier runs can fill the first pages: page on until this
|
|
// test's own record is compacted, or the sweep has reached the end.
|
|
export async function sweepUntil(retention, done) {
|
|
for (let page = 0; page < 1000; page++) {
|
|
const result = await retention.sweep();
|
|
if (await done()) return true;
|
|
if (!result.next) return done();
|
|
}
|
|
return done();
|
|
}
|