From 79babb2e24908bf20d96859b45647d7b7fcae845 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Wed, 20 Jul 2022 14:32:01 -0400 Subject: [PATCH] test: handle Int32s --- .../client-side-encryption/driver.test.js | 23 +++++++++++-------- test/tools/spec-runner/matcher.js | 4 ++++ test/tools/unified-spec-runner/runner.ts | 6 ++--- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/test/integration/client-side-encryption/driver.test.js b/test/integration/client-side-encryption/driver.test.js index 1d6f5b84e3..2097dffa80 100644 --- a/test/integration/client-side-encryption/driver.test.js +++ b/test/integration/client-side-encryption/driver.test.js @@ -7,6 +7,13 @@ const chai = require('chai'); const expect = chai.expect; chai.use(require('chai-subset')); +const metadata = { + requires: { + mongodb: '>=4.2.0', + clientSideEncryption: true + } +}; + describe('Client Side Encryption Functional', function () { const dataDbName = 'db'; const dataCollName = 'coll'; @@ -14,13 +21,6 @@ describe('Client Side Encryption Functional', function () { const keyVaultCollName = 'datakeys'; const keyVaultNamespace = `${keyVaultDbName}.${keyVaultCollName}`; - const metadata = { - requires: { - mongodb: '>=4.2.0', - clientSideEncryption: true - } - }; - it('CSFLE_KMS_PROVIDERS should be valid EJSON', function () { if (process.env.CSFLE_KMS_PROVIDERS) { /** @@ -228,6 +228,9 @@ describe('Client Side Encryption Functional', function () { let collection; beforeEach(async function () { + if (this.configuration.clientSideEncryption == null) { + return; + } const encryptionOptions = { monitorCommands: true, autoEncryption: { @@ -244,7 +247,7 @@ describe('Client Side Encryption Functional', function () { }); describe('find', () => { - it('should maintain ordered sort', async function () { + it('should maintain ordered sort', metadata, async function () { const events = []; client.on('commandStarted', ev => events.push(ev)); const sort = new Map([ @@ -259,7 +262,7 @@ describe('Client Side Encryption Functional', function () { }); describe('findAndModify', () => { - it('should maintain ordered sort', async function () { + it('should maintain ordered sort', metadata, async function () { const events = []; client.on('commandStarted', ev => events.push(ev)); const sort = new Map([ @@ -274,7 +277,7 @@ describe('Client Side Encryption Functional', function () { }); describe('createIndexes', () => { - it('should maintain ordered index keys', async function () { + it('should maintain ordered index keys', metadata, async function () { const events = []; client.on('commandStarted', ev => events.push(ev)); const indexDescription = new Map([ diff --git a/test/tools/spec-runner/matcher.js b/test/tools/spec-runner/matcher.js index 757b049d4a..6ea9b5a0cd 100644 --- a/test/tools/spec-runner/matcher.js +++ b/test/tools/spec-runner/matcher.js @@ -118,6 +118,10 @@ function generateMatchAndDiffSpecialCase(key, expectedObj, actualObj, metadata) function generateMatchAndDiff(expected, actual, metadata) { const typeOfExpected = typeof expected; + if (typeOfExpected === 'object' && expected._bsontype === 'Int32' && typeof actual === 'number') { + return { match: expected.value === actual, expected, actual }; + } + if (typeOfExpected !== typeof actual) { return { match: false, expected, actual }; } diff --git a/test/tools/unified-spec-runner/runner.ts b/test/tools/unified-spec-runner/runner.ts index a5bed8e474..5f37f3467f 100644 --- a/test/tools/unified-spec-runner/runner.ts +++ b/test/tools/unified-spec-runner/runner.ts @@ -40,7 +40,7 @@ async function terminateOpenTransactions(client: MongoClient) { * @param skipFilter - a function that returns null if the test should be run, * or a skip reason if the test should be skipped */ -export async function runUnifiedTest( +async function runUnifiedTest( ctx: Mocha.Context, unifiedSuite: uni.UnifiedSuite, test: uni.Test, @@ -256,8 +256,8 @@ export function runUnifiedSuite( ): void { for (const unifiedSuite of specTests) { context(String(unifiedSuite.description), function () { - for (const test of unifiedSuite.tests) { - it(String(test.description), async function () { + for (const [index, test] of unifiedSuite.tests.entries()) { + it(String(test.description === '' ? `Test ${index}` : test.description), async function () { await runUnifiedTest(this, unifiedSuite, test, skipFilter); }); }