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 Dec 17, 2018
1 parent e3781b6 commit c58b103
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 174 deletions.
54 changes: 28 additions & 26 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,34 +418,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
186 changes: 48 additions & 138 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
"exports-loader": "~0.7.0",
"expose-loader": "~0.7.5",
"faker": "~4.1.0",
"gulp-mocha": "~3.0.1",
"gulp-mocha": "~6.0.0",
"gulp-nodemon": "~2.4.2",
"imports-loader": "~0.8.0",
"jasmine-core": "~3.3.0",
Expand Down

0 comments on commit c58b103

Please sign in to comment.