MCPcopy
hub / github.com/mongodb/node-mongodb-native / testConnection

Function testConnection

test/manual/socks5.test.ts:299–312  ·  view source on GitHub ↗
(connectionString, clientOptions)

Source from the content-addressed store, hash-verified

297});
298
299async function testConnection(connectionString, clientOptions) {
300 const client = new MongoClient(connectionString, clientOptions);
301 let topologyType;
302 client.on('topologyDescriptionChanged', ev => (topologyType = ev.newDescription.type));
303
304 try {
305 await client.connect();
306 await client.db('admin').command({ hello: 1 });
307 await client.db('test').collection('test').findOne({});
308 } finally {
309 await client.close();
310 }
311 return topologyType;
312}

Callers 1

socks5.test.tsFile · 0.85

Calls 7

connectMethod · 0.95
dbMethod · 0.95
closeMethod · 0.95
onMethod · 0.80
findOneMethod · 0.80
collectionMethod · 0.65
commandMethod · 0.45

Tested by

no test coverage detected