Skip to content

Commit

Permalink
Merge branch 'main' into NODE-3681/current-date-type
Browse files Browse the repository at this point in the history
  • Loading branch information
aditi-khare-mongoDB committed Mar 19, 2024
2 parents 366eee9 + 8b91c30 commit 1c62069
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 33 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
"@typescript-eslint",
"prettier",
"unused-imports",
"tsdoc"
"tsdoc",
"mocha"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
// "plugin:mocha/recommended"
],
"env": {
"node": true,
Expand Down Expand Up @@ -112,6 +114,7 @@
]
}
],
"mocha/no-async-describe": "error",
"no-restricted-syntax": [
"error",
{
Expand Down
57 changes: 54 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"eslint": "^8.56.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-mocha": "^10.4.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-tsdoc": "^0.2.17",
Expand Down
2 changes: 1 addition & 1 deletion test/atlas/drivers_atlas_testing.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { runUnifiedSuite } from '../tools/unified-spec-runner/runner';

describe('Node Driver Atlas Testing', async function () {
describe('Node Driver Atlas Testing', function () {
// Astrolabe can, well, take some time. In some cases up to 800s to
// reconfigure clusters.
this.timeout(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { EJSON } from 'bson';
import { expect } from 'chai';
import { readFile } from 'fs/promises';
import { join } from 'path';
import * as semver from 'semver';

import { Decimal128, type Document, Double, Long, type MongoClient } from '../../../src';
/* eslint-disable @typescript-eslint/no-restricted-imports */
Expand All @@ -25,7 +24,9 @@ const metaData: MongoDBMetadataUI = {

// The Range Explicit Encryption tests require MongoDB server 7.0+ for QE v2.
// The tests must not run against a standalone.
mongodb: '>=7.0.0',
//
// `rangePreview` is not supported on 8.0+ servers.
mongodb: '>=7.0.0 <8.0.0',
topology: '!single'
}
};
Expand Down Expand Up @@ -127,14 +128,6 @@ const readEncryptedFieldsFile = (dataType: string): Promise<string> =>
describe('Range Explicit Encryption', function () {
installNodeDNSWorkaroundHooks();

beforeEach(async function () {
if (semver.gte(this.configuration.version, '7.999.999')) {
if (this.currentTest)
this.currentTest.skipReason = 'TODO(NODE-5908): skip rangePreview tests on server 8.0+';
return this.currentTest?.skip();
}
});

let clientEncryption;
let keyId;
let keyVaultClient;
Expand All @@ -145,7 +138,7 @@ describe('Range Explicit Encryption', function () {
let encryptedTwoHundred;
let compareNumericValues;
for (const { type: dataType, rangeOptions, factory } of dataTypes) {
context(`datatype ${dataType}`, async function () {
context(`datatype ${dataType}`, function () {
beforeEach(async function () {
compareNumericValues = function (value: unknown, expected: number): void {
if (dataType === 'DoubleNoPrecision' || dataType === 'DoublePrecision') {
Expand Down
6 changes: 3 additions & 3 deletions test/integration/crud/abstract_operation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { executeOperation, Long, Server } from '../../mongodb';
import * as mongodb from '../../mongodb';
import { topologyWithPlaceholderClient } from '../../tools/utils';

describe('abstract operation', async function () {
describe('command name getter', async function () {
describe('abstract operation', function () {
describe('command name getter', function () {
interface AbstractOperationSubclasses {
subclassCreator: () => mongodb.AbstractOperation;
subclassType: any;
Expand Down Expand Up @@ -312,7 +312,7 @@ describe('abstract operation', async function () {
});

for (const { subclassCreator, subclassType, correctCommandName } of subclassArray) {
context(`when subclass is ${subclassType.name}`, async function () {
context(`when subclass is ${subclassType.name}`, function () {
it(`operation.commandName equals correct string`, async function () {
const subclassInstance = subclassCreator();
expect(subclassInstance.commandName).to.equal(correctCommandName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('useBigInt64 option', function () {
}
});

describe('when not provided to client', async function () {
describe('when not provided to client', function () {
beforeEach(async function () {
client = await this.configuration.newClient().connect();
});
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('useBigInt64 option', function () {
});
});

describe('when set to true at collection level', async function () {
describe('when set to true at collection level', function () {
let res: WithId<BSON.Document> | null;
beforeEach(async function () {
client = await this.configuration.newClient().connect();
Expand All @@ -110,7 +110,7 @@ describe('useBigInt64 option', function () {
});
});

describe('when set to false at collection level', async function () {
describe('when set to false at collection level', function () {
let res: WithId<BSON.Document> | null;
beforeEach(async function () {
client = await this.configuration.newClient().connect();
Expand Down
4 changes: 2 additions & 2 deletions test/unit/cmap/connect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ describe('Connect Tests', function () {
expect(handshakeDocument.client.env).to.not.have.property('name');
});

context('when 512 byte size limit is exceeded', async () => {
context('when 512 byte size limit is exceeded', () => {
it(`should not 'env' property in client`, async () => {
// make metadata = 507 bytes, so it takes up entire LimitedSizeDocument
const longAppName = 's'.repeat(493);
Expand Down Expand Up @@ -274,7 +274,7 @@ describe('Connect Tests', function () {
expect(handshakeDocument.client.env.name).to.equal('aws.lambda');
});

context('when 512 byte size limit is exceeded', async () => {
context('when 512 byte size limit is exceeded', () => {
it(`should not have 'container' property in client.env`, async () => {
// make metadata = 507 bytes, so it takes up entire LimitedSizeDocument
const longAppName = 's'.repeat(447);
Expand Down
2 changes: 1 addition & 1 deletion test/unit/commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe('class OpCompressedRequest', () => {
});
});

context('toBin()', async () => {
context('toBin()', () => {
for (const protocol of [OpMsgRequest, OpQueryRequest]) {
context(`when ${protocol.name} is used`, () => {
let msg;
Expand Down
12 changes: 6 additions & 6 deletions test/unit/mongo_logger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('meta tests for BufferingStream', function () {
});
});

describe('class MongoLogger', async function () {
describe('class MongoLogger', function () {
describe('#constructor()', function () {
it('assigns each property from the options object onto the logging class', function () {
const componentSeverities: MongoLoggerOptions['componentSeverities'] = {
Expand Down Expand Up @@ -1353,7 +1353,7 @@ describe('class MongoLogger', async function () {
});
});

describe('log', async function () {
describe('log', function () {
let componentSeverities: MongoLoggerOptions['componentSeverities'];

beforeEach(function () {
Expand Down Expand Up @@ -1407,7 +1407,7 @@ describe('class MongoLogger', async function () {
});
});
});
describe('async stream failure handling', async function () {
describe('async stream failure handling', function () {
context('when stream is not stderr', function () {
let stderrStub;

Expand All @@ -1419,7 +1419,7 @@ describe('class MongoLogger', async function () {
sinon.restore();
});

context('when stream user defined stream and stream.write throws async', async function () {
context('when stream user defined stream and stream.write throws async', function () {
it('should catch error, not crash application, warn user, and start writing to stderr', async function () {
const stream = {
async write(_log) {
Expand Down Expand Up @@ -1456,7 +1456,7 @@ describe('class MongoLogger', async function () {
});
});

context('when stream is stdout and stdout.write throws', async function () {
context('when stream is stdout and stdout.write throws', function () {
it('should catch error, not crash application, warn user, and start writing to stderr', async function () {
sinon.stub(process.stdout, 'write').throws(new Error('I am stdout and do not work'));
// print random message at the debug level
Expand Down Expand Up @@ -1509,7 +1509,7 @@ describe('class MongoLogger', async function () {
});
});
});
context('when async stream has multiple logs with different timeouts', async function () {
context('when async stream has multiple logs with different timeouts', function () {
it('should preserve their order', async function () {
const stream = {
buffer: [],
Expand Down
4 changes: 2 additions & 2 deletions test/unit/sdam/server_selection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import * as mock from '../../tools/mongodb-mock/index';
import { topologyWithPlaceholderClient } from '../../tools/utils';

describe('server selection', async function () {
describe('server selection', function () {
const primary = new ServerDescription('127.0.0.1:27017', {
setName: 'test',
isWritablePrimary: true,
Expand Down Expand Up @@ -610,7 +610,7 @@ describe('server selection', async function () {
});
});

describe('server selection logging feature flagging', async function () {
describe('server selection logging feature flagging', function () {
let mockServer;
let topology;
let address;
Expand Down

0 comments on commit 1c62069

Please sign in to comment.