diff --git a/test/functional/shared.js b/test/functional/shared.js index 1499936f19..db05c51b65 100644 --- a/test/functional/shared.js +++ b/test/functional/shared.js @@ -1,4 +1,5 @@ -var MongoClient = require('../../').MongoClient; +var MongoClient = require('../../').MongoClient, + expect = require('chai').expect; function connectToDb(url, db, options, callback) { if (typeof options === 'function') { @@ -12,6 +13,30 @@ function connectToDb(url, db, options, callback) { }); } +function setupDatabase(configuration) { + var dbName = configuration.db; + var client = configuration.newClient(configuration.writeConcernMax(), { + poolSize: 1 + }); + + return client.connect().then(function() { + var db = client.db(dbName); + return db.dropDatabase(); + }); +} + +var assert = { + equal: function(a, b) { + expect(a).to.equal(b); + }, + + ok: function(a) { + expect(a).to.be.ok; + } +}; + module.exports = { - connectToDb: connectToDb + connectToDb: connectToDb, + setupDatabase: setupDatabase, + assert: assert };