MCPcopy
hub / github.com/mongodb/node-mongodb-native / testBulkWrite

Function testBulkWrite

test/unit/collection.test.ts:110–140  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

108
109 context('#bulkWrite', () => {
110 async function testBulkWrite(config) {
111 const client = new MongoClient(`mongodb://${server.uri()}/test`);
112
113 server.setMessageHandler(request => {
114 const doc = request.document;
115 if (doc.insert) {
116 expect(doc.bypassDocumentValidation).equal(config.expected);
117 request.reply({
118 ok: 1
119 });
120 }
121
122 if (isHello(doc)) {
123 request.reply(Object.assign({}, HELLO));
124 } else if (doc.endSessions) {
125 request.reply({ ok: 1 });
126 }
127 });
128
129 await client.connect();
130 const db = client.db('test');
131 const collection = db.collection('test_c');
132
133 const options = {
134 bypassDocumentValidation: config.actual,
135 ordered: config.ordered
136 };
137
138 await collection.bulkWrite([{ insertOne: { document: { a: 1 } } }], options);
139 await client.close();
140 }
141
142 // ordered bulk write, testing change in ordered.js
143 it('should only set bypass document validation if strictly true in ordered bulkWrite', async function () {

Callers 1

collection.test.tsFile · 0.85

Calls 8

connectMethod · 0.95
dbMethod · 0.95
closeMethod · 0.95
isHelloFunction · 0.90
setMessageHandlerMethod · 0.80
collectionMethod · 0.65
uriMethod · 0.45
bulkWriteMethod · 0.45

Tested by

no test coverage detected