From f536f2255f125a714e5a3228d973ae8de4bc72ce Mon Sep 17 00:00:00 2001 From: Jason Fox Date: Wed, 25 Nov 2020 15:36:17 +0100 Subject: [PATCH 1/2] Amend connection code. --- test/tools/mongoDBUtils.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/tools/mongoDBUtils.js b/test/tools/mongoDBUtils.js index 5d6052f..5fc1e31 100644 --- a/test/tools/mongoDBUtils.js +++ b/test/tools/mongoDBUtils.js @@ -27,16 +27,14 @@ const async = require('async'); function cleanDb(host, name, callback) { const url = 'mongodb://' + host + ':27017/' + name; - MongoClient.connect( - url, - function(err, db) { - if (db) { - db.dropDatabase(); + MongoClient.connect(url, { useNewUrlParser: true }, function (err, db) { + if (db && db.db()) { + db.db().dropDatabase(function (err, result) { db.close(); - } - callback(); + callback(); + }); } - ); + }); } function cleanDbs(host, callback) { From c6bbd985d7edce1ef0769519237898b40062fb2f Mon Sep 17 00:00:00 2001 From: Jason Fox Date: Wed, 25 Nov 2020 15:44:39 +0100 Subject: [PATCH 2/2] Add lint exception --- test/tools/mongoDBUtils.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/tools/mongoDBUtils.js b/test/tools/mongoDBUtils.js index 5fc1e31..a42195a 100644 --- a/test/tools/mongoDBUtils.js +++ b/test/tools/mongoDBUtils.js @@ -27,8 +27,10 @@ const async = require('async'); function cleanDb(host, name, callback) { const url = 'mongodb://' + host + ':27017/' + name; + /* eslint-disable-next-line no-unused-vars */ MongoClient.connect(url, { useNewUrlParser: true }, function (err, db) { if (db && db.db()) { + /* eslint-disable-next-line no-unused-vars */ db.db().dropDatabase(function (err, result) { db.close(); callback();