Skip to content

Commit 2f57933

Browse files
authored
Merge pull request #163 from gregolsky/v4.0
add test loading more than 1024 docs at once with session.load()
2 parents dadfcd4 + 896c974 commit 2f57933

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

test/Issues/RDBC-244.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import * as assert from "assert";
2+
import { testContext, disposeTestDocumentStore } from "../Utils/TestUtil";
3+
4+
import {
5+
IDocumentStore,
6+
} from "../../src";
7+
8+
describe("RDBC-244", function () {
9+
10+
let store: IDocumentStore;
11+
12+
beforeEach(async function () {
13+
testContext.customizeStore = async (store) => {
14+
store.conventions.findCollectionNameForObjectLiteral = x => "test";
15+
};
16+
store = await testContext.getDocumentStore();
17+
});
18+
19+
afterEach(async () => {
20+
await disposeTestDocumentStore(store);
21+
});
22+
23+
it("can load more than 1024 docs in a single load", async () => {
24+
25+
const items = [];
26+
{
27+
const bulk = store.bulkInsert();
28+
for (let i = 0; i < 1500; i++) {
29+
const item = {
30+
name: "Margarette" + i
31+
};
32+
await bulk.store(item);
33+
items.push(item);
34+
}
35+
36+
await bulk.finish();
37+
}
38+
39+
const moreThan1024Ids = items.map(x => x.id);
40+
assert.strictEqual(moreThan1024Ids.length, 1500);
41+
42+
{
43+
const session = store.openSession();
44+
const loaded = await session.load(moreThan1024Ids);
45+
assert.strictEqual(Object.keys(loaded).length, 1500);
46+
assert.ok(Object.keys(loaded)
47+
.reduce((result, item) => [...result, loaded[item]], [])
48+
.every(x => x));
49+
}
50+
});
51+
});

0 commit comments

Comments
 (0)