Skip to content

Commit 96a8512

Browse files
committed
test: fix missing insertedIds in spec tests
1 parent 2395095 commit 96a8512

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
@@ -535,8 +535,8 @@ function executeCommands(
535535
}
536536

537537
// Merge the results together
538-
const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult);
539538
const mergeResult = mergeBatchResults(batch, bulkOperation.s.bulkResult, err, result);
539+
const writeResult = new BulkWriteResult(bulkOperation.s.bulkResult);
540540
if (mergeResult != null) {
541541
return callback(undefined, writeResult);
542542
}
@@ -1233,7 +1233,6 @@ export abstract class BulkOperationBase {
12331233
this.s.executed = true;
12341234
const finalOptions = { ...this.s.options, ...options };
12351235
const operation = new BulkWriteShimOperation(this, finalOptions);
1236-
12371236
return executeOperation(this.s.collection.s.db.s.client, operation);
12381237
}, callback);
12391238
}

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

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

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

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

0 commit comments

Comments
 (0)