Skip to content

Commit 1d0bb60

Browse files
committed
remove logging from vm context, remove runNodelessTests
1 parent 5c3fcfa commit 1d0bb60

4 files changed

Lines changed: 17 additions & 42 deletions

File tree

etc/build-runtime-barrel.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const source = useBundled ? './mongodb_bundled' : './mongodb';
1313
const contents =
1414
`// This file is auto-generated. Do not edit.\n` +
1515
`// Run 'npm run build:runtime-barrel' to regenerate.\n` +
16-
`export const runNodelessTests = ${useBundled};\n` +
1716
`export * from '${source}';\n`;
1817
await fs.writeFile(outputBarrelFile, contents);
1918

test/integration/crud/crud_api.test.ts

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ import {
1313
type MongoClient,
1414
MongoServerError,
1515
ObjectId,
16-
ReturnDocument,
17-
runNodelessTests
16+
ReturnDocument
1817
} from '../../mongodb_runtime-testing';
1918
import { ensureTypeByName, type FailCommandFailPoint } from '../../tools/utils';
2019
import { assert as test } from '../shared';
2120

2221
const DB_NAME = 'crud_api_tests';
2322

24-
describe('CRUD API', function () {
23+
describe.only('CRUD API', function () {
2524
let client: MongoClient;
2625

2726
beforeEach(async function () {
@@ -104,13 +103,9 @@ describe('CRUD API', function () {
104103
const spy = sinon.spy(Collection.prototype, 'find');
105104
const result = await collection.findOne({});
106105
expect(result).to.deep.equal({ _id: 1 });
107-
if (runNodelessTests) {
108-
ensureTypeByName(events.at(0), 'CommandSucceededEvent');
109-
} else {
110-
expect(events.at(0)).to.be.instanceOf(CommandSucceededEvent);
111-
expect(spy.returnValues.at(0)).to.have.property('closed', true);
112-
expect(spy.returnValues.at(0)).to.have.nested.property('session.hasEnded', true);
113-
}
106+
expect(events.at(0)).to.be.instanceOf(CommandSucceededEvent);
107+
expect(spy.returnValues.at(0)).to.have.property('closed', true);
108+
expect(spy.returnValues.at(0)).to.have.nested.property('session.hasEnded', true);
114109
});
115110
});
116111

@@ -140,14 +135,10 @@ describe('CRUD API', function () {
140135
it('the cursor for findOne is closed', async function () {
141136
const spy = sinon.spy(Collection.prototype, 'find');
142137
const error = await collection.findOne({}).catch(error => error);
143-
if (runNodelessTests) {
144-
ensureTypeByName(error, 'MongoServerError');
145-
} else {
146-
expect(error).to.be.instanceOf(MongoServerError);
147-
expect(events.at(0)).to.be.instanceOf(CommandFailedEvent);
148-
expect(spy.returnValues.at(0)).to.have.property('closed', true);
149-
expect(spy.returnValues.at(0)).to.have.nested.property('session.hasEnded', true);
150-
}
138+
expect(error).to.be.instanceOf(MongoServerError);
139+
expect(events.at(0)).to.be.instanceOf(CommandFailedEvent);
140+
expect(spy.returnValues.at(0)).to.have.property('closed', true);
141+
expect(spy.returnValues.at(0)).to.have.nested.property('session.hasEnded', true);
151142
});
152143
});
153144
});
@@ -182,13 +173,9 @@ describe('CRUD API', function () {
182173
const spy = sinon.spy(Collection.prototype, 'aggregate');
183174
const result = await collection.countDocuments({});
184175
expect(result).to.deep.equal(2);
185-
if (runNodelessTests) {
186-
ensureTypeByName(events[0], 'CommandSucceededEvent');
187-
} else {
188-
expect(events[0]).to.be.instanceOf(CommandSucceededEvent);
189-
expect(spy.returnValues[0]).to.have.property('closed', true);
190-
expect(spy.returnValues[0]).to.have.nested.property('session.hasEnded', true);
191-
}
176+
expect(events[0]).to.be.instanceOf(CommandSucceededEvent);
177+
expect(spy.returnValues[0]).to.have.property('closed', true);
178+
expect(spy.returnValues[0]).to.have.nested.property('session.hasEnded', true);
192179
});
193180
});
194181

@@ -218,14 +205,10 @@ describe('CRUD API', function () {
218205
it('the cursor for countDocuments is closed', async function () {
219206
const spy = sinon.spy(Collection.prototype, 'aggregate');
220207
const error = await collection.countDocuments({}).catch(error => error);
221-
if (runNodelessTests) {
222-
ensureTypeByName(error, 'MongoServerError');
223-
} else {
224-
expect(error).to.be.instanceOf(MongoServerError);
225-
expect(events.at(0)).to.be.instanceOf(CommandFailedEvent);
226-
expect(spy.returnValues.at(0)).to.have.property('closed', true);
227-
expect(spy.returnValues.at(0)).to.have.nested.property('session.hasEnded', true);
228-
}
208+
expect(error).to.be.instanceOf(MongoServerError);
209+
expect(events.at(0)).to.be.instanceOf(CommandFailedEvent);
210+
expect(spy.returnValues.at(0)).to.have.property('closed', true);
211+
expect(spy.returnValues.at(0)).to.have.nested.property('session.hasEnded', true);
229212
});
230213
});
231214
});
@@ -802,11 +785,7 @@ describe('CRUD API', function () {
802785
.bulkWrite(ops, { ordered: false, writeConcern: { w: 1 } })
803786
.catch(error => error);
804787

805-
if (runNodelessTests) {
806-
ensureTypeByName(error, 'MongoBulkWriteError');
807-
} else {
808-
expect(error).to.be.instanceOf(MongoBulkWriteError);
809-
}
788+
expect(error).to.be.instanceOf(MongoBulkWriteError);
810789
// 1004 because one of them is duplicate key
811790
// but since it is unordered we continued to write
812791
expect(error).to.have.property('insertedCount', 1004);

test/mongodb_runtime-testing.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
// This file is auto-generated. Do not edit.
22
// Run 'npm run build:runtime-barrel' to regenerate.
3-
export const runNodelessTests = false;
43
export * from './mongodb';

test/tools/runner/vm_context_helper.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ function createRestrictedRequire() {
2828

2929
if (isAllowed) {
3030
// Allow access to the module if the requester is in the allowlist
31-
console.log(`Allowing access to core module '${moduleName}' for ${srcRelativePath}`);
3231
} else {
33-
console.log(`Blocking access to core module '${moduleName}' from ${srcRelativePath}`);
3432
throw new Error(
3533
`Access to core module '${moduleName}' from ${srcRelativePath} is restricted in this context`
3634
);

0 commit comments

Comments
 (0)