Skip to content

Commit 51873e2

Browse files
committed
test: fix missing insertedIds in spec tests
1 parent 556816f commit 51873e2

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/bulk/common.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,8 @@ function executeCommands(
530530
}
531531

532532
// Merge the results together
533-
const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult);
534533
const mergeResult = mergeBatchResults(batch, bulkOperation.s.bulkResult, err, result);
534+
const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult);
535535
if (mergeResult != null) {
536536
return callback(undefined, writeResult);
537537
}
@@ -1226,7 +1226,6 @@ export abstract class BulkOperationBase {
12261226
this.s.executed = true;
12271227
const finalOptions = { ...this.s.options, ...options };
12281228
const operation = new BulkWriteShimOperation(this, finalOptions);
1229-
12301229
return executeOperation(this.s.collection.s.db.s.client, operation);
12311230
}, callback);
12321231
}

test/tools/unified-spec-runner/operations.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,21 @@ operations.set('rewrapManyDataKey', async ({ entities, operation }) => {
659659
const clientEncryption = entities.getEntity('clientEncryption', operation.object);
660660
const { filter, opts } = operation.arguments!;
661661

662-
return await clientEncryption.rewrapManyDataKey(filter, opts);
662+
const rewrapManyDataKeyResult = await clientEncryption.rewrapManyDataKey(filter, opts);
663+
if (rewrapManyDataKeyResult.bulkWriteResult != null) {
664+
// TODO: Create DRIVERS ticket.
665+
//
666+
// The unified spec runner match function will assert that documents have no extra
667+
// keys. For `rewrapManyDataKey` operations, our unifed tests will fail because
668+
// our BulkWriteResult class has an insertedIds property, which is correct by the
669+
// spec but not defined in the spec tests.
670+
const { bulkWriteResult } = rewrapManyDataKeyResult;
671+
Object.defineProperty(bulkWriteResult, 'insertedIds', {
672+
value: bulkWriteResult.insertedIds,
673+
enumerable: false
674+
});
675+
}
676+
return rewrapManyDataKeyResult;
663677
});
664678

665679
operations.set('deleteKey', async ({ entities, operation }) => {

0 commit comments

Comments
 (0)