Skip to content

Commit b6cc34e

Browse files
committed
feat(shared): add helper utilities for assertion and suite setup
NODE-1095
1 parent 988d95a commit b6cc34e

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

test/functional/shared.js

+27-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
var MongoClient = require('../../').MongoClient;
1+
var MongoClient = require('../../').MongoClient,
2+
expect = require('chai').expect;
23

34
function connectToDb(url, db, options, callback) {
45
if (typeof options === 'function') {
@@ -12,6 +13,30 @@ function connectToDb(url, db, options, callback) {
1213
});
1314
}
1415

16+
function setupDatabase(configuration) {
17+
var dbName = configuration.db;
18+
var client = configuration.newClient(configuration.writeConcernMax(), {
19+
poolSize: 1
20+
});
21+
22+
return client.connect().then(function() {
23+
var db = client.db(dbName);
24+
return db.dropDatabase();
25+
});
26+
}
27+
28+
var assert = {
29+
equal: function(a, b) {
30+
expect(a).to.equal(b);
31+
},
32+
33+
ok: function(a) {
34+
expect(a).to.be.ok;
35+
}
36+
};
37+
1538
module.exports = {
16-
connectToDb: connectToDb
39+
connectToDb: connectToDb,
40+
setupDatabase: setupDatabase,
41+
assert: assert
1742
};

0 commit comments

Comments
 (0)