Skip to content

Commit

Permalink
test: handle Int32s
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Jul 20, 2022
1 parent eb78d8e commit 79babb2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
23 changes: 13 additions & 10 deletions test/integration/client-side-encryption/driver.test.js
Expand Up @@ -7,20 +7,20 @@ 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';
const keyVaultDbName = 'keyvault';
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) {
/**
Expand Down Expand Up @@ -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: {
Expand All @@ -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([
Expand All @@ -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([
Expand All @@ -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([
Expand Down
4 changes: 4 additions & 0 deletions test/tools/spec-runner/matcher.js
Expand Up @@ -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 };
}
Expand Down
6 changes: 3 additions & 3 deletions test/tools/unified-spec-runner/runner.ts
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
});
}
Expand Down

0 comments on commit 79babb2

Please sign in to comment.