Skip to content

Commit 33d71dd

Browse files
committed
test: handle Int32s
1 parent 35964c8 commit 33d71dd

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

test/integration/client-side-encryption/driver.test.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ const chai = require('chai');
77
const expect = chai.expect;
88
chai.use(require('chai-subset'));
99

10+
const metadata = {
11+
requires: {
12+
mongodb: '>=4.2.0',
13+
clientSideEncryption: true
14+
}
15+
};
16+
1017
describe('Client Side Encryption Functional', function () {
1118
const dataDbName = 'db';
1219
const dataCollName = 'coll';
1320
const keyVaultDbName = 'keyvault';
1421
const keyVaultCollName = 'datakeys';
1522
const keyVaultNamespace = `${keyVaultDbName}.${keyVaultCollName}`;
1623

17-
const metadata = {
18-
requires: {
19-
mongodb: '>=4.2.0',
20-
clientSideEncryption: true
21-
}
22-
};
23-
2424
it('CSFLE_KMS_PROVIDERS should be valid EJSON', function () {
2525
if (process.env.CSFLE_KMS_PROVIDERS) {
2626
/**
@@ -228,6 +228,9 @@ describe('Client Side Encryption Functional', function () {
228228
let collection;
229229

230230
beforeEach(async function () {
231+
if (this.configuration.clientSideEncryption == null) {
232+
return;
233+
}
231234
const encryptionOptions = {
232235
monitorCommands: true,
233236
autoEncryption: {
@@ -244,7 +247,7 @@ describe('Client Side Encryption Functional', function () {
244247
});
245248

246249
describe('find', () => {
247-
it('should maintain ordered sort', async function () {
250+
it('should maintain ordered sort', metadata, async function () {
248251
const events = [];
249252
client.on('commandStarted', ev => events.push(ev));
250253
const sort = new Map([
@@ -259,7 +262,7 @@ describe('Client Side Encryption Functional', function () {
259262
});
260263

261264
describe('findAndModify', () => {
262-
it('should maintain ordered sort', async function () {
265+
it('should maintain ordered sort', metadata, async function () {
263266
const events = [];
264267
client.on('commandStarted', ev => events.push(ev));
265268
const sort = new Map([
@@ -274,7 +277,7 @@ describe('Client Side Encryption Functional', function () {
274277
});
275278

276279
describe('createIndexes', () => {
277-
it('should maintain ordered index keys', async function () {
280+
it('should maintain ordered index keys', metadata, async function () {
278281
const events = [];
279282
client.on('commandStarted', ev => events.push(ev));
280283
const indexDescription = new Map([

test/tools/spec-runner/matcher.js

+4
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ function generateMatchAndDiffSpecialCase(key, expectedObj, actualObj, metadata)
118118
function generateMatchAndDiff(expected, actual, metadata) {
119119
const typeOfExpected = typeof expected;
120120

121+
if (typeOfExpected === 'object' && expected._bsontype === 'Int32' && typeof actual === 'number') {
122+
return { match: expected.value === actual, expected, actual };
123+
}
124+
121125
if (typeOfExpected !== typeof actual) {
122126
return { match: false, expected, actual };
123127
}

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ async function terminateOpenTransactions(client: MongoClient) {
4040
* @param skipFilter - a function that returns null if the test should be run,
4141
* or a skip reason if the test should be skipped
4242
*/
43-
export async function runUnifiedTest(
43+
async function runUnifiedTest(
4444
ctx: Mocha.Context,
4545
unifiedSuite: uni.UnifiedSuite,
4646
test: uni.Test,
@@ -256,8 +256,8 @@ export function runUnifiedSuite(
256256
): void {
257257
for (const unifiedSuite of specTests) {
258258
context(String(unifiedSuite.description), function () {
259-
for (const test of unifiedSuite.tests) {
260-
it(String(test.description), async function () {
259+
for (const [index, test] of unifiedSuite.tests.entries()) {
260+
it(String(test.description === '' ? `Test ${index}` : test.description), async function () {
261261
await runUnifiedTest(this, unifiedSuite, test, skipFilter);
262262
});
263263
}

0 commit comments

Comments
 (0)