Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 17 additions & 19 deletions test/action/dependency.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as path from 'node:path';
import { expect } from 'chai';

import { dependencies, peerDependencies, peerDependenciesMeta } from '../../package.json';
import { setDifference } from '../mongodb';
import { setDifference } from '../../src/utils';
import { alphabetically, itInNodeProcess, sorted } from '../tools/utils';

const EXPECTED_DEPENDENCIES = sorted(
Expand Down Expand Up @@ -82,16 +82,15 @@ describe('package.json', function () {
});

if (depName === 'snappy') {
itInNodeProcess(
'getSnappy returns rejected import',
async function ({ expect, mongodb }) {
const snappyImport = mongodb.getSnappy();
expect(snappyImport).to.have.nested.property(
'kModuleError.name',
'MongoMissingDependencyError'
);
}
);
itInNodeProcess('getSnappy returns rejected import', async function ({ expect }) {
// @ts-expect-error: import from the inside forked process
const { getSnappy } = await import('./src/deps.ts');
const snappyImport = getSnappy();
expect(snappyImport).to.have.nested.property(
'kModuleError.name',
'MongoMissingDependencyError'
);
});
}
});

Expand All @@ -111,14 +110,13 @@ describe('package.json', function () {
});

if (depName === 'snappy') {
itInNodeProcess(
'getSnappy returns fulfilled import',
async function ({ expect, mongodb }) {
const snappyImport = mongodb.getSnappy();
expect(snappyImport).to.have.property('compress').that.is.a('function');
expect(snappyImport).to.have.property('uncompress').that.is.a('function');
}
);
itInNodeProcess('getSnappy returns fulfilled import', async function ({ expect }) {
// @ts-expect-error: import from the inside forked process
const { getSnappy } = await import('./src/deps.ts');
const snappyImport = getSnappy();
expect(snappyImport).to.have.property('compress').that.is.a('function');
expect(snappyImport).to.have.property('uncompress').that.is.a('function');
});
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const { MongoClient } = require('../../../mongodb');
const { MongoClient } = require('mongodb');

// Yes, we are shadowing a global here but we are not actually ever printing anything in this file
// This just so the examples can use console.log to make for nice copy pasting
Expand Down
2 changes: 1 addition & 1 deletion test/integration/node-specific/examples/versioned_api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use strict';
const { MongoClient } = require('../../../mongodb');
const { MongoClient } = require('mongodb');

describe('examples.versionedApi:', function () {
let uri;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,20 @@ import { AssertionError, expect } from 'chai';
import type * as timers from 'timers';
import { parseSnapshot } from 'v8-heapsnapshot';

import type * as mongodb from '../../mongodb';
import { type MongoClient } from '../../mongodb';
import type * as mongodb from '../../../src';
import { type TestConfiguration } from '../../tools/runner/config';
import { type sleep } from '../../tools/utils';

export type ResourceTestFunction = HeapResourceTestFunction | ProcessResourceTestFunction;

export type HeapResourceTestFunction = (options: {
MongoClient: typeof MongoClient;
MongoClient: typeof mongodb.MongoClient;
uri: string;
iteration: number;
}) => Promise<void>;

export type ProcessResourceTestFunction = (options: {
MongoClient: typeof MongoClient;
MongoClient: typeof mongodb.MongoClient;
uri?: string;
log?: (out: any) => void;
expect: typeof expect;
Expand Down
4 changes: 3 additions & 1 deletion test/mocha_mongodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ module.exports = {
'test/integration/node-specific/examples/handler.test.js',
'test/integration/node-specific/examples/aws_handler.js',
'test/integration/node-specific/examples/aws_handler.test.js',
'test/integration/node-specific/examples/setup.js'
'test/integration/node-specific/examples/setup.js',
'test/integration/node-specific/examples/transactions.test.js',
'test/integration/node-specific/examples/versioned_api.js'
],
'node-option': Number(major) >= 23 ? ['no-experimental-strip-types'] : undefined
};
140 changes: 0 additions & 140 deletions test/mongodb.ts

This file was deleted.

2 changes: 1 addition & 1 deletion test/tools/mongodb-mock/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const Request = require('./request');
const { Query } = require('./protocol');
const EventEmitter = require('events');
const { setTimeout } = require('timers');
const { HostAddress } = require('../../../mongodb');
const { HostAddress } = require('../../../../src/utils');

/*
* MockServer class
Expand Down
12 changes: 4 additions & 8 deletions test/tools/runner/hooks/legacy_crud_shims.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,21 @@ const legacyUsageMaximums = {
};

// @ts-expect-error: Method no longer exists on Collection
Collection.prototype.insert = function (docs, options, callback) {
Collection.prototype.insert = function (docs, options) {
legacyUsageCounts.insert += 1;
callback =
typeof callback === 'function' ? callback : typeof options === 'function' ? options : undefined;
options = options != null && typeof options === 'object' ? options : { ordered: false };

docs = Array.isArray(docs) ? docs : [docs];

return this.insertMany(docs, options, callback);
return this.insertMany(docs, options);
};

// @ts-expect-error: Method no longer exists on Collection
Collection.prototype.update = function (filter, update, options, callback) {
Collection.prototype.update = function (filter, update, options) {
legacyUsageCounts.update += 1;
callback =
typeof callback === 'function' ? callback : typeof options === 'function' ? options : undefined;
options = options != null && typeof options === 'object' ? options : {};

return this.updateMany(filter, update, options, callback);
return this.updateMany(filter, update, options);
};

function assertLegacyAPIUsageDoesNotIncrease() {
Expand Down
4 changes: 2 additions & 2 deletions test/tools/spec-runner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ const chai = require('chai');

const expect = chai.expect;
const { EJSON } = require('bson');
const { isRecord } = require('../../mongodb');
const { isRecord } = require('../../../src/utils');
const TestRunnerContext = require('./context').TestRunnerContext;
const resolveConnectionString = require('./utils').resolveConnectionString;
const {
LEGACY_HELLO_COMMAND,
CMAP_EVENTS: SOURCE_CMAP_EVENTS,
TOPOLOGY_EVENTS,
HEARTBEAT_EVENTS
} = require('../../mongodb');
} = require('../../../src/constants');
const { isAnyRequirementSatisfied } = require('../unified-spec-runner/unified-utils');
const { getCSFLEKMSProviders } = require('../../csfle-kms-providers');

Expand Down
7 changes: 3 additions & 4 deletions test/tools/unified-spec-runner/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,20 @@ import {
type MongoCredentials,
ReadConcern,
ReadPreference,
SENSITIVE_COMMANDS,
type ServerClosedEvent,
type ServerDescriptionChangedEvent,
type ServerHeartbeatFailedEvent,
type ServerHeartbeatStartedEvent,
type ServerHeartbeatSucceededEvent,
type ServerOpeningEvent,
Timeout,
TimeoutError,
type TopologyClosedEvent,
type TopologyDescription,
type TopologyDescriptionChangedEvent,
type TopologyOpeningEvent,
WriteConcern
} from '../../mongodb';
} from '../../../src';
import { SENSITIVE_COMMANDS } from '../../../src/cmap/command_monitoring_events';
import { Timeout, TimeoutError } from '../../../src/timeout';
import { getEncryptExtraOptions, getEnvironmentalOptions } from '../../tools/utils';
import { AlpineTestConfiguration, type TestConfiguration } from '../runner/config';
import { EntityEventRegistry } from './entity_event_registry';
Expand Down
2 changes: 1 addition & 1 deletion test/tools/unified-spec-runner/match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
TopologyClosedEvent,
TopologyDescriptionChangedEvent,
TopologyOpeningEvent
} from '../../mongodb';
} from '../../../src';
import { ejson } from '../utils';
import { type CmapEvent, type CommandEvent, type EntitiesMap, type SdamEvent } from './entities';
import {
Expand Down
6 changes: 3 additions & 3 deletions test/tools/unified-spec-runner/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { gte as semverGte, satisfies as semverSatisfies } from 'semver';

import {
type MongoClient,
MONGODB_ERROR_CODES,
MongoParseError,
MongoServerError,
ns,
ReadPreference,
TopologyType
} from '../../mongodb';
} from '../../../src';
import { MONGODB_ERROR_CODES } from '../../../src/error';
import { ns } from '../../../src/utils';
import { ejson } from '../utils';
import { AstrolabeResultsWriter } from './astrolabe_results_writer';
import { EntitiesMap, type UnifiedMongoClient } from './entities';
Expand Down
2 changes: 1 addition & 1 deletion test/tools/unified-spec-runner/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
TagSet,
TopologyType,
W
} from '../../mongodb';
} from '../../../src';
import { type TestConfiguration } from '../runner/config';
import { type UnifiedThread } from './entities';

Expand Down
8 changes: 4 additions & 4 deletions test/tools/unified-spec-runner/unified-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import ConnectionString from 'mongodb-connection-string-url';
import { coerce, gte as semverGte, lte as semverLte } from 'semver';
import { isDeepStrictEqual } from 'util';

import { ClientEncryption } from '../../../src/client-side-encryption/client_encryption';
import { getCSFLEKMSProviders } from '../../csfle-kms-providers';
import {
type AutoEncryptionOptions,
type CollectionOptions,
type DbOptions,
type Document,
getMongoDBClientEncryption,
type MongoClient,
ReturnDocument
} from '../../mongodb';
} from '../../../src';
import { ClientEncryption } from '../../../src/client-side-encryption/client_encryption';
import { getMongoDBClientEncryption } from '../../../src/deps';
import { getCSFLEKMSProviders } from '../../csfle-kms-providers';
import type { CmapEvent, CommandEvent, EntitiesMap, SdamEvent } from './entities';
import { matchesEvents } from './match';
import { MalformedOperationError } from './operations';
Expand Down
Loading