Skip to content

Commit

Permalink
Move connecting and dropping DB to loadmodels file
Browse files Browse the repository at this point in the history
  • Loading branch information
Jagjeet committed Nov 11, 2018
1 parent a4fcbda commit 009abe7
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 177 deletions.
54 changes: 28 additions & 26 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,34 +437,36 @@ function mocha(done) {
var testSuites = changedTestFiles.length ? changedTestFiles : testAssets.tests.server;
var error;

// Connect mongoose
mongooseService.connect(function (db) {
// Clean out test database to have clean base
mongooseService.dropDatabase(db, function () {
gulp.src(testSuites)
.pipe(plugins.mocha({
reporter: 'spec',
timeout: 10000,
file: './testutils/loadmodels.testutil'
}))
.on('error', function (err) {
// If an error occurs, save it
error = err;
console.error(err);
})
.on('end', function () {
// When the tests are done, disconnect agenda/mongoose
// and pass the error state back to gulp
// @TODO: https://github.com/Trustroots/trustroots/issues/438
// @link https://github.com/agenda/agenda/pull/450
agenda._mdb.close(function () {
mongooseService.disconnect(function () {
done(error);
});
});
gulp.src(testSuites)
.pipe(plugins.mocha({
reporter: 'spec',
timeout: 10000,
delay: true,
exit: true,
file: './testutils/loadmodels.testutil'
}))
.on('error', function (err) {
// If an error occurs, save it
error = err;
console.error(err);
// Close the DB connection
agenda._mdb.close(function () {
mongooseService.disconnect(function () {
done(error);
});
});
})
.on('end', function () {
// When the tests are done, disconnect agenda/mongoose
// and pass the error state back to gulp
// @TODO: https://github.com/Trustroots/trustroots/issues/438
// @link https://github.com/agenda/agenda/pull/450
agenda._mdb.close(function () {
mongooseService.disconnect(function () {
done(error);
});
});
});
});
}

function karma(done) {
Expand Down

0 comments on commit 009abe7

Please sign in to comment.