forked from mystiq/hydrogen-web
make backfill limit explicit
This commit is contained in:
parent
dd71fdbe08
commit
4b7cb6da9e
1 changed files with 7 additions and 7 deletions
|
@ -312,9 +312,9 @@ export function tests() {
|
|||
};
|
||||
}
|
||||
|
||||
async function backfillAndWrite(mocks, fragmentEntry) {
|
||||
async function backfillAndWrite(mocks, fragmentEntry, limit) {
|
||||
const {txn, timelineMock, gapWriter} = mocks;
|
||||
const messageResponse = timelineMock.messages(fragmentEntry.token, undefined, fragmentEntry.direction.asApiString());
|
||||
const messageResponse = timelineMock.messages(fragmentEntry.token, undefined, fragmentEntry.direction.asApiString(), limit);
|
||||
await gapWriter.writeFragmentFill(fragmentEntry, messageResponse, txn, logger);
|
||||
}
|
||||
|
||||
|
@ -348,7 +348,7 @@ export function tests() {
|
|||
const { timelineMock } = mocks;
|
||||
timelineMock.append(30);
|
||||
const {fragmentEntry} = await syncAndWrite(mocks);
|
||||
await backfillAndWrite(mocks, fragmentEntry);
|
||||
await backfillAndWrite(mocks, fragmentEntry, 10);
|
||||
const events = await allFragmentEvents(mocks, fragmentEntry.fragmentId);
|
||||
assert.deepEqual(events.map(e => e.event_id), eventIds(10, 30));
|
||||
await mocks.txn.complete();
|
||||
|
@ -360,7 +360,7 @@ export function tests() {
|
|||
const {syncResponse, fragmentEntry: firstFragmentEntry} = await syncAndWrite(mocks, { limit: 10 });
|
||||
timelineMock.append(15);
|
||||
const {fragmentEntry: secondFragmentEntry} = await syncAndWrite(mocks, { previous: syncResponse, limit: 10 });
|
||||
await backfillAndWrite(mocks, secondFragmentEntry);
|
||||
await backfillAndWrite(mocks, secondFragmentEntry, 10);
|
||||
|
||||
const firstFragment = await fetchFragment(mocks, firstFragmentEntry.fragmentId);
|
||||
const secondFragment = await fetchFragment(mocks, secondFragmentEntry.fragmentId);
|
||||
|
@ -378,7 +378,7 @@ export function tests() {
|
|||
const {syncResponse, fragmentEntry: firstFragmentEntry} = await syncAndWrite(mocks, { limit: 10 });
|
||||
timelineMock.append(20);
|
||||
const {fragmentEntry: secondFragmentEntry} = await syncAndWrite(mocks, { previous: syncResponse, limit: 10 });
|
||||
await backfillAndWrite(mocks, secondFragmentEntry);
|
||||
await backfillAndWrite(mocks, secondFragmentEntry, 10);
|
||||
|
||||
const firstFragment = await fetchFragment(mocks, firstFragmentEntry.fragmentId);
|
||||
const secondFragment = await fetchFragment(mocks, secondFragmentEntry.fragmentId);
|
||||
|
@ -397,7 +397,7 @@ export function tests() {
|
|||
// Mess with the saved token to receive old events in backfill
|
||||
fragmentEntry.token = syncResponse.next_batch;
|
||||
txn.timelineFragments.update(fragmentEntry.fragment);
|
||||
await backfillAndWrite(mocks, fragmentEntry);
|
||||
await backfillAndWrite(mocks, fragmentEntry, 10);
|
||||
|
||||
const fragment = await fetchFragment(mocks, fragmentEntry.fragmentId);
|
||||
assert.notEqual(fragment.nextId, fragment.id);
|
||||
|
@ -412,7 +412,7 @@ export function tests() {
|
|||
timelineMock.append(11);
|
||||
const {fragmentEntry: secondFragmentEntry} = await syncAndWrite(mocks, { previous: syncResponse, limit: 10 });
|
||||
timelineMock.insertAfter(eventId(9), 5);
|
||||
await backfillAndWrite(mocks, secondFragmentEntry);
|
||||
await backfillAndWrite(mocks, secondFragmentEntry, 10);
|
||||
|
||||
const firstEvents = await allFragmentEvents(mocks, firstFragmentEntry.fragmentId);
|
||||
assert.deepEqual(firstEvents.map(e => e.event_id), eventIds(0, 10));
|
||||
|
|
Loading…
Reference in a new issue