Skip to content

Commit 7d879fd

Browse files
authored
test(NODE-7280): remove test/mongodb.ts and its usage (#4766)
1 parent 8e95b0d commit 7d879fd

File tree

16 files changed

+47
-194
lines changed

16 files changed

+47
-194
lines changed

test/action/dependency.test.ts

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as path from 'node:path';
55
import { expect } from 'chai';
66

77
import { dependencies, peerDependencies, peerDependenciesMeta } from '../../package.json';
8-
import { setDifference } from '../mongodb';
8+
import { setDifference } from '../../src/utils';
99
import { alphabetically, itInNodeProcess, sorted } from '../tools/utils';
1010

1111
const EXPECTED_DEPENDENCIES = sorted(
@@ -82,16 +82,15 @@ describe('package.json', function () {
8282
});
8383

8484
if (depName === 'snappy') {
85-
itInNodeProcess(
86-
'getSnappy returns rejected import',
87-
async function ({ expect, mongodb }) {
88-
const snappyImport = mongodb.getSnappy();
89-
expect(snappyImport).to.have.nested.property(
90-
'kModuleError.name',
91-
'MongoMissingDependencyError'
92-
);
93-
}
94-
);
85+
itInNodeProcess('getSnappy returns rejected import', async function ({ expect }) {
86+
// @ts-expect-error: import from the inside forked process
87+
const { getSnappy } = await import('./src/deps.ts');
88+
const snappyImport = getSnappy();
89+
expect(snappyImport).to.have.nested.property(
90+
'kModuleError.name',
91+
'MongoMissingDependencyError'
92+
);
93+
});
9594
}
9695
});
9796

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

113112
if (depName === 'snappy') {
114-
itInNodeProcess(
115-
'getSnappy returns fulfilled import',
116-
async function ({ expect, mongodb }) {
117-
const snappyImport = mongodb.getSnappy();
118-
expect(snappyImport).to.have.property('compress').that.is.a('function');
119-
expect(snappyImport).to.have.property('uncompress').that.is.a('function');
120-
}
121-
);
113+
itInNodeProcess('getSnappy returns fulfilled import', async function ({ expect }) {
114+
// @ts-expect-error: import from the inside forked process
115+
const { getSnappy } = await import('./src/deps.ts');
116+
const snappyImport = getSnappy();
117+
expect(snappyImport).to.have.property('compress').that.is.a('function');
118+
expect(snappyImport).to.have.property('uncompress').that.is.a('function');
119+
});
122120
}
123121
});
124122
}

test/integration/node-specific/examples/transactions.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const { MongoClient } = require('../../../mongodb');
3+
const { MongoClient } = require('mongodb');
44

55
// Yes, we are shadowing a global here but we are not actually ever printing anything in this file
66
// This just so the examples can use console.log to make for nice copy pasting

test/integration/node-specific/examples/versioned_api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use strict';
2-
const { MongoClient } = require('../../../mongodb');
2+
const { MongoClient } = require('mongodb');
33

44
describe('examples.versionedApi:', function () {
55
let uri;

test/integration/node-specific/resource_tracking_script_builder.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,20 @@ import { AssertionError, expect } from 'chai';
99
import type * as timers from 'timers';
1010
import { parseSnapshot } from 'v8-heapsnapshot';
1111

12-
import type * as mongodb from '../../mongodb';
13-
import { type MongoClient } from '../../mongodb';
12+
import type * as mongodb from '../../../src';
1413
import { type TestConfiguration } from '../../tools/runner/config';
1514
import { type sleep } from '../../tools/utils';
1615

1716
export type ResourceTestFunction = HeapResourceTestFunction | ProcessResourceTestFunction;
1817

1918
export type HeapResourceTestFunction = (options: {
20-
MongoClient: typeof MongoClient;
19+
MongoClient: typeof mongodb.MongoClient;
2120
uri: string;
2221
iteration: number;
2322
}) => Promise<void>;
2423

2524
export type ProcessResourceTestFunction = (options: {
26-
MongoClient: typeof MongoClient;
25+
MongoClient: typeof mongodb.MongoClient;
2726
uri?: string;
2827
log?: (out: any) => void;
2928
expect: typeof expect;

test/mocha_mongodb.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ module.exports = {
2727
'test/integration/node-specific/examples/handler.test.js',
2828
'test/integration/node-specific/examples/aws_handler.js',
2929
'test/integration/node-specific/examples/aws_handler.test.js',
30-
'test/integration/node-specific/examples/setup.js'
30+
'test/integration/node-specific/examples/setup.js',
31+
'test/integration/node-specific/examples/transactions.test.js',
32+
'test/integration/node-specific/examples/versioned_api.js'
3133
],
3234
'node-option': Number(major) >= 23 ? ['no-experimental-strip-types'] : undefined
3335
};

test/mongodb.ts

Lines changed: 0 additions & 140 deletions
This file was deleted.

test/tools/mongodb-mock/src/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const Request = require('./request');
99
const { Query } = require('./protocol');
1010
const EventEmitter = require('events');
1111
const { setTimeout } = require('timers');
12-
const { HostAddress } = require('../../../mongodb');
12+
const { HostAddress } = require('../../../../src/utils');
1313

1414
/*
1515
* MockServer class

test/tools/runner/hooks/legacy_crud_shims.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,21 @@ const legacyUsageMaximums = {
1414
};
1515

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

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

25-
return this.insertMany(docs, options, callback);
23+
return this.insertMany(docs, options);
2624
};
2725

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

35-
return this.updateMany(filter, update, options, callback);
31+
return this.updateMany(filter, update, options);
3632
};
3733

3834
function assertLegacyAPIUsageDoesNotIncrease() {

test/tools/spec-runner/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ const chai = require('chai');
55

66
const expect = chai.expect;
77
const { EJSON } = require('bson');
8-
const { isRecord } = require('../../mongodb');
8+
const { isRecord } = require('../../../src/utils');
99
const TestRunnerContext = require('./context').TestRunnerContext;
1010
const resolveConnectionString = require('./utils').resolveConnectionString;
1111
const {
1212
LEGACY_HELLO_COMMAND,
1313
CMAP_EVENTS: SOURCE_CMAP_EVENTS,
1414
TOPOLOGY_EVENTS,
1515
HEARTBEAT_EVENTS
16-
} = require('../../mongodb');
16+
} = require('../../../src/constants');
1717
const { isAnyRequirementSatisfied } = require('../unified-spec-runner/unified-utils');
1818
const { getCSFLEKMSProviders } = require('../../csfle-kms-providers');
1919

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,20 @@ import {
3434
type MongoCredentials,
3535
ReadConcern,
3636
ReadPreference,
37-
SENSITIVE_COMMANDS,
3837
type ServerClosedEvent,
3938
type ServerDescriptionChangedEvent,
4039
type ServerHeartbeatFailedEvent,
4140
type ServerHeartbeatStartedEvent,
4241
type ServerHeartbeatSucceededEvent,
4342
type ServerOpeningEvent,
44-
Timeout,
45-
TimeoutError,
4643
type TopologyClosedEvent,
4744
type TopologyDescription,
4845
type TopologyDescriptionChangedEvent,
4946
type TopologyOpeningEvent,
5047
WriteConcern
51-
} from '../../mongodb';
48+
} from '../../../src';
49+
import { SENSITIVE_COMMANDS } from '../../../src/cmap/command_monitoring_events';
50+
import { Timeout, TimeoutError } from '../../../src/timeout';
5251
import { getEncryptExtraOptions, getEnvironmentalOptions } from '../../tools/utils';
5352
import { AlpineTestConfiguration, type TestConfiguration } from '../runner/config';
5453
import { EntityEventRegistry } from './entity_event_registry';

0 commit comments

Comments
 (0)