Skip to content

Commit

Permalink
feat(shared): add helper utilities for assertion and suite setup
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Sep 1, 2017
1 parent 988d95a commit b6cc34e
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions test/functional/shared.js
Original file line number Diff line number Diff line change
@@ -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') {
Expand All @@ -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
};

0 comments on commit b6cc34e

Please sign in to comment.