Skip to content

Commit 8b56601

Browse files
committed
feat(NODE-7223): run checkout on connect regardless of credentials
1 parent 5db818c commit 8b56601

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

test/integration/node-specific/mongo_client.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,29 @@ describe('class MongoClient', function () {
339339
});
340340
});
341341

342+
it('throws ENOTFOUND error when connecting to non-existent host with no auth and loadBalanced=true', async function () {
343+
const configuration = this.configuration;
344+
const client = configuration.newClient(
345+
'mongodb://iLoveJavaScript:27017/test?loadBalanced=true',
346+
{ serverSelectionTimeoutMS: 100 }
347+
);
348+
349+
const error = await client.connect().catch(error => error);
350+
expect(error).to.be.instanceOf(MongoNetworkError); // not server selection like other topologies
351+
expect(error.message).to.match(/ENOTFOUND/);
352+
});
353+
354+
it('throws an error when srv is not a real record', async function () {
355+
const client = this.configuration.newClient('mongodb+srv://iLoveJavaScript/test', {
356+
serverSelectionTimeoutMS: 100
357+
});
358+
359+
const error = await client.connect().catch(error => error);
360+
expect(error).to.be.instanceOf(Error);
361+
expect(error.message).to.match(/ENOTFOUND/);
362+
});
363+
});
364+
342365
it('Should correctly pass through appname', async function () {
343366
const configuration = this.configuration;
344367
const options = {

0 commit comments

Comments
 (0)