From 075e66cdde51a7a135d2e3cdf38eb1f5dc3f49a0 Mon Sep 17 00:00:00 2001 From: Liran Tal Date: Thu, 5 Jan 2017 11:01:03 +0200 Subject: [PATCH] fix(seed): gulp task `test:seed` would hang on the gulp node process and not exit the mongoose and sequelize connections were not closing, therefore leaving an event listener open for connections and hanging the node.js process waiting for more work. By closing the connections on both the gulp process is able to quit after performing the seed tasks. --- server/gulpfile.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/gulpfile.js b/server/gulpfile.js index 76cc90fa8..1191bf2a7 100644 --- a/server/gulpfile.js +++ b/server/gulpfile.js @@ -218,29 +218,36 @@ gulp.task('ava:test:integration', function() { }); }); +// Connects to Mongoose based on environment settings and seeds the database, performing +// a drop of the mongo database to clear it out gulp.task('seed:mongoose', function(done) { const mongoose = require('./config/lib/mongoose'); mongoose.connect() .then(mongoose.seed) + .then(mongoose.disconnect) .then(function() { done(); }); }); +// Connects to an SQL database, drop and re-create the schemas gulp.task('seed:sequelize', function(done) { const sequelize = require('./config/lib/sequelize'); sequelize.seed() .then(function() { + sequelize.sequelize.close(); done(); - }); + }); }); +// Performs database seeding, used in test environments and related tasks gulp.task('test:seed', function(done) { runSequence('seed:mongoose', 'seed:sequelize', done); }); +// Run Integration Tests gulp.task('test:integration', function(done) { runSequence('env:test', 'server:bootstrap', 'ava:test:integration', done); });