Skip to content

Commit

Permalink
fix(seed): gulp task test:seed would hang on the gulp node process …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
lirantal committed Jan 5, 2017
1 parent 9dfb3df commit 075e66c
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion server/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit 075e66c

Please sign in to comment.