Skip to content

Commit 38c3b9e

Browse files
committed
add simple hilo next range test
1 parent 9f860e7 commit 38c3b9e

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/Ported/HiLoTest.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,4 +219,31 @@ describe("HiLo", function () {
219219
assert.ok(parseInt(numericPart, 10) < 33);
220220
});
221221
});
222+
223+
it("does get another range when gets over max and leaves no gaps", async () => {
224+
const parallelLevel = 40;
225+
const users = Array.from(Array(parallelLevel).keys()).map(x => new User());
226+
227+
const tasks = Array.from(Array(parallelLevel).keys()).map(async i => {
228+
const user = users[i];
229+
const session = store.openSession();
230+
await session.store(user);
231+
await session.saveChanges();
232+
});
233+
234+
await Promise.all(tasks);
235+
236+
const idNumbers = users
237+
.map(x => x.id)
238+
.map(id => id.split("/")[1])
239+
.map(x => parseInt(x.split("-")[0], 10));
240+
241+
assert.strictEqual(idNumbers.length, 40);
242+
243+
idNumbers.sort((a, b) => a > b ? 1 : -1);
244+
245+
for (let i = 1; i <= 40; i++) {
246+
assert.strictEqual(idNumbers[i - 1], i);
247+
}
248+
});
222249
});

0 commit comments

Comments
 (0)