Skip to content

Commit

Permalink
test: add concurrency test
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-pousette committed Jul 21, 2024
1 parent 2480ea7 commit 2bc15a6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/utils/indexer/tests/src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3368,6 +3368,28 @@ export const tests = (
}
});

describe("concurrency", () => {
it("can handle concurrent counts", async () => {
let results: number[] = [];
let promises: Promise<void>[] = [];
await setupDefault();
for (let i = 0; i < 100; i++) {
promises.push(
(async () => {
results.push(await store.count(new CountRequest()));
})(),
);
}
await Promise.all(promises);
expect(results).to.have.length(100);
try {
expect(results.every((x) => x === 4)).to.be.true;
} catch (error) {
console.log(results);
throw error;
}
});
});
describe("drop", () => {
it("store", async () => {
let { directory, indices, store } = await setupDefault();
Expand Down

0 comments on commit 2bc15a6

Please sign in to comment.