Skip to content

Commit 6fc9085

Browse files
chore(NODE-7428): import from mongodb.ts file in tests instead of src (#4864)
Co-authored-by: Sergey Zelenov <sergey.zelenov@mongodb.com>
1 parent e465058 commit 6fc9085

File tree

279 files changed

+1024
-794
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

279 files changed

+1024
-794
lines changed

.eslintrc.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@
186186
{
187187
"patterns": [
188188
"**/../lib/**",
189+
"**/../src/**",
189190
"mongodb-mock-server"
190191
]
191192
}
@@ -224,7 +225,8 @@
224225
{
225226
"patterns": [
226227
"**/../lib/**",
227-
"mongodb-mock-server"
228+
"mongodb-mock-server",
229+
"**/../src/**"
228230
]
229231
}
230232
]
@@ -331,6 +333,15 @@
331333
"disallowTypeAnnotations": false,
332334
"fixStyle": "separate-type-imports"
333335
}
336+
],
337+
"no-restricted-imports": [
338+
"error",
339+
{
340+
"patterns": [
341+
"**/../lib/**",
342+
"**/../src/**"
343+
]
344+
}
334345
]
335346
}
336347
}

src/cmap/auth/mongodb_oidc.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import type { Connection } from '../connection';
55
import { type AuthContext, AuthProvider } from './auth_provider';
66
import type { MongoCredentials } from './mongo_credentials';
77
import { AutomatedCallbackWorkflow } from './mongodb_oidc/automated_callback_workflow';
8-
import { callback as azureCallback } from './mongodb_oidc/azure_machine_workflow';
9-
import { callback as gcpCallback } from './mongodb_oidc/gcp_machine_workflow';
10-
import { callback as k8sCallback } from './mongodb_oidc/k8s_machine_workflow';
8+
import { azureCallback } from './mongodb_oidc/azure_machine_workflow';
9+
import { gcpCallback } from './mongodb_oidc/gcp_machine_workflow';
10+
import { k8sCallback } from './mongodb_oidc/k8s_machine_workflow';
1111
import { TokenCache } from './mongodb_oidc/token_cache';
12-
import { callback as testCallback } from './mongodb_oidc/token_machine_workflow';
12+
import { tokenMachineCallback as testCallback } from './mongodb_oidc/token_machine_workflow';
1313

1414
/** Error when credentials are missing. */
1515
const MISSING_CREDENTIALS_ERROR = 'AuthContext must provide credentials.';

src/cmap/auth/mongodb_oidc/azure_machine_workflow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const TOKEN_RESOURCE_MISSING_ERROR =
1919
* @param params - The OIDC callback parameters.
2020
* @returns The OIDC response.
2121
*/
22-
export const callback: OIDCCallbackFunction = async (
22+
export const azureCallback: OIDCCallbackFunction = async (
2323
params: OIDCCallbackParams
2424
): Promise<OIDCResponse> => {
2525
const tokenAudience = params.tokenAudience;

src/cmap/auth/mongodb_oidc/gcp_machine_workflow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const TOKEN_RESOURCE_MISSING_ERROR =
1818
* @param params - The OIDC callback parameters.
1919
* @returns The OIDC response.
2020
*/
21-
export const callback: OIDCCallbackFunction = async (
21+
export const gcpCallback: OIDCCallbackFunction = async (
2222
params: OIDCCallbackParams
2323
): Promise<OIDCResponse> => {
2424
const tokenAudience = params.tokenAudience;

src/cmap/auth/mongodb_oidc/k8s_machine_workflow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const AWS_FILENAME = 'AWS_WEB_IDENTITY_TOKEN_FILE';
1717
* @param params - The OIDC callback parameters.
1818
* @returns The OIDC response.
1919
*/
20-
export const callback: OIDCCallbackFunction = async (): Promise<OIDCResponse> => {
20+
export const k8sCallback: OIDCCallbackFunction = async (): Promise<OIDCResponse> => {
2121
let filename: string;
2222
if (process.env[AZURE_FILENAME]) {
2323
filename = process.env[AZURE_FILENAME];

src/cmap/auth/mongodb_oidc/token_machine_workflow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const TOKEN_MISSING_ERROR = 'OIDC_TOKEN_FILE must be set in the environment.';
1212
* @param params - The OIDC callback parameters.
1313
* @returns The OIDC response.
1414
*/
15-
export const callback: OIDCCallbackFunction = async (): Promise<OIDCResponse> => {
15+
export const tokenMachineCallback: OIDCCallbackFunction = async (): Promise<OIDCResponse> => {
1616
const tokenFile = process.env.OIDC_TOKEN_FILE;
1717
if (!tokenFile) {
1818
throw new MongoAWSError(TOKEN_MISSING_ERROR);

test/action/dependency.test.ts

Lines changed: 2 additions & 1 deletion
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 '../../src/utils';
8+
import { setDifference } from '../mongodb';
99
import { alphabetically, itInNodeProcess, sorted } from '../tools/utils';
1010

1111
const EXPECTED_DEPENDENCIES = sorted(
@@ -139,6 +139,7 @@ describe('package.json', function () {
139139

140140
beforeEach(async function () {
141141
for (const key of Object.keys(require.cache)) delete require.cache[key];
142+
// Intentionally import from `src` because we are testing the package's exports (index.ts)
142143
// eslint-disable-next-line @typescript-eslint/no-require-imports
143144
require('../../src');
144145
imports = Array.from(

test/benchmarks/unitBench/list.bench.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const chalk = require('chalk');
2-
const { List } = require('../../../src/utils');
2+
const { List } = require('../../mongodb');
33
const { createHistogram } = require('perf_hooks');
44
const { process } = require('process');
55

test/csfle-kms-providers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as process from 'process';
22

3-
import { type KMSProviders } from './../src';
3+
import { type KMSProviders } from './mongodb';
44

55
const csfleKMSProviders = {
66
aws: {

test/integration/auth/auth.prose.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { expect } from 'chai';
22
import * as process from 'process';
33
import * as sinon from 'sinon';
44

5-
import { type MongoClient } from '../../../src';
6-
import { ScramSHA256 } from '../../../src/cmap/auth/scram';
7-
import { Connection } from '../../../src/cmap/connection';
8-
import { LEGACY_HELLO_COMMAND } from '../../../src/constants';
5+
import { Connection, LEGACY_HELLO_COMMAND, type MongoClient, ScramSHA256 } from '../../mongodb';
96
import { type TestConfiguration } from '../../tools/runner/config';
107

118
function makeConnectionString(config, username, password) {

0 commit comments

Comments
 (0)