Skip to content

Commit 748325c

Browse files
misc fixes
- fix lint configuration to restrict imports from src - auto fix import order in all test files - fix error tests, which were failing and skipped - unskip driver import tests
1 parent 19dc794 commit 748325c

10 files changed

Lines changed: 23 additions & 463 deletions

File tree

.eslintrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@
225225
{
226226
"patterns": [
227227
"**/../lib/**",
228-
"mongodb-mock-server"
228+
"mongodb-mock-server",
229+
"**/../src/**"
229230
]
230231
}
231232
]

test/mongodb.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// As the centralized import for all src code for tests, we intentionally import from `src` in this file.
2+
/* eslint-disable @typescript-eslint/no-restricted-imports */
3+
14
export * from '../src/admin';
25
export * from '../src/bson';
36
export * from '../src/bulk/common';
@@ -111,6 +114,7 @@ export * from '../src/operations/update';
111114
export * from '../src/operations/validate_collection';
112115
export * from '../src/read_concern';
113116
export * from '../src/read_preference';
117+
export * from '../src/runtime_adapters';
114118
export * from '../src/sdam/common';
115119
export * from '../src/sdam/events';
116120
export * from '../src/sdam/monitor';
@@ -127,4 +131,3 @@ export * from '../src/timeout';
127131
export * from '../src/transactions';
128132
export * from '../src/utils';
129133
export * from '../src/write_concern';
130-
export * from '../src/runtime_adapters';

test/tools/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ import {
1717
type HostAddress,
1818
MongoClient,
1919
type MongoClientOptions,
20-
type Runtime,
21-
type ServerApiVersion,
22-
type TopologyOptions,
2320
OP_MSG,
2421
processTimeMS,
22+
resolveRuntimeAdapters,
23+
type Runtime,
24+
type ServerApiVersion,
2525
Topology,
26-
resolveRuntimeAdapters
26+
type TopologyOptions
2727
} from '../mongodb';
2828
import { type TestConfiguration } from './runner/config';
2929
import { isTLSEnabled } from './runner/filters/tls_filter';

test/unit/assorted/imports.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function* walk(root) {
1515
}
1616
}
1717

18-
describe.skip('importing mongodb driver', () => {
18+
describe('importing mongodb driver', () => {
1919
const sourceFiles = walk(path.resolve(__dirname, '../../../src'));
2020

2121
for (const sourceFile of sourceFiles) {

test/unit/client-side-encryption/providers/credentialsProvider.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import * as process from 'process';
44
import * as sinon from 'sinon';
55

66
// Intentionally import from src, because we need to stub the `get()` function.
7+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
78
import * as utils from '../../../../src/utils';
89
import {
910
AWSSDKCredentialProvider,

test/unit/cmap/handshake/client_metadata.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ import * as sinon from 'sinon';
66
import { inspect } from 'util';
77

88
import { version as NODE_DRIVER_VERSION } from '../../../../package.json';
9-
import { runtime } from '../../../tools/utils';
10-
119
import {
1210
getFAASEnv,
1311
LimitedSizeDocument,
1412
makeClientMetadata,
1513
MongoInvalidArgumentError
1614
} from '../../../mongodb';
15+
import { runtime } from '../../../tools/utils';
1716
describe('client metadata module', () => {
1817
afterEach(() => sinon.restore());
1918

test/unit/commands.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { expect } from 'chai';
22
import * as sinon from 'sinon';
33

4+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
45
import * as compression from '../../src/cmap/wire_protocol/compression';
56
import {
67
compress,

test/unit/error.test.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { expect } from 'chai';
22
import { setTimeout } from 'timers';
33

4+
// Exception to the import from mongodb rule we're unit testing our public Errors API
5+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
46
import * as importsFromErrorSrc from '../../src/error';
7+
// eslint-disable-next-line @typescript-eslint/no-restricted-imports
8+
import * as importsFromEntryPoint from '../../src/index';
59
import {
610
DeprioritizedServers,
711
isHello,
@@ -25,31 +29,29 @@ import {
2529
needsRetryableWriteLabel,
2630
NODE_IS_RECOVERING_ERROR_MESSAGE,
2731
ns,
28-
PoolClosedError,
32+
PoolClosedError as MongoPoolClosedError,
2933
RunCommandOperation,
3034
setDifference,
3135
TimeoutContext,
3236
type Topology,
3337
type TopologyDescription,
3438
type TopologyOptions,
35-
WaitQueueTimeoutError
39+
WaitQueueTimeoutError as MongoWaitQueueTimeoutError
3640
} from '../mongodb';
37-
// Exception to the import from mongodb rule we're unit testing our public Errors API
38-
import * as importsFromEntryPoint from '../mongodb';
3941
import { ReplSetFixture } from '../tools/common';
4042
import { cleanup } from '../tools/mongodb-mock/index';
4143
import { topologyWithPlaceholderClient } from '../tools/utils';
4244

43-
describe.skip('MongoErrors', () => {
45+
describe('MongoErrors', () => {
4446
let errorClassesFromEntryPoint = Object.fromEntries(
4547
Object.entries(importsFromEntryPoint).filter(
4648
([key, value]) => key.endsWith('Error') && value.toString().startsWith('class')
4749
)
4850
) as any;
4951
errorClassesFromEntryPoint = {
5052
...errorClassesFromEntryPoint,
51-
PoolClosedError,
52-
WaitQueueTimeoutError
53+
MongoPoolClosedError,
54+
MongoWaitQueueTimeoutError
5355
};
5456

5557
const errorClassesFromErrorSrc = Object.fromEntries(

update-imports.ts

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

0 commit comments

Comments
 (0)