Skip to content

Commit

Permalink
Add assertion for skipping index creation on same keys (gridfs).
Browse files Browse the repository at this point in the history
  • Loading branch information
sekko27 committed Aug 10, 2022
1 parent bb276f9 commit ddb9811
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/cases/06_gridfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,19 @@ testWithClient(
"GridFS: Creating indexes - skip index creation on same index keys",
async (client) => {
const addAsset = async (index: number) => {
const bucket = new GridFSBucket(client.database("test"), {
const db = client.database("test");
const bucket = new GridFSBucket(db, {
bucketName: "sameKeys",
});
const upstream = await bucket.openUploadStream(`test-asset-${index}`);
const writer = upstream.getWriter();
await writer.write(new TextEncoder().encode(`[asset${index}]`));
await writer.close();
return {
files: await db.collection("sameKeys.files").listIndexes().toArray(),
chunks: await db.collection("sameKeys.chunks").listIndexes().toArray(),
};
};
await addAsset(0);
await addAsset(1);
assertEquals(await addAsset(0), await addAsset(1));
},
);

0 comments on commit ddb9811

Please sign in to comment.