Skip to content

Commit

Permalink
Add test for promises in config files.
Browse files Browse the repository at this point in the history
  • Loading branch information
wwalser committed Nov 22, 2016
1 parent b49276a commit 61878ee
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions test/db/migrate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,60 @@ describe(Support.getTestDialectTeaser('db:migrate'), function () {
});
});

describe(Support.getTestDialectTeaser('db:migrate'), function () {
describe('with promise in config.js', function () {
var prepare = function (callback) {
var config = helpers.getTestConfig();
var configContent = '' +
'var b = require("bluebird");' +
'module.exports = b.resolve(' + JSON.stringify(config) + ');';
var result = '';

return gulp
.src(Support.resolveSupportPath('tmp'))
.pipe(helpers.clearDirectory())
.pipe(helpers.runCli('init'))
.pipe(helpers.removeFile('config/config.json'))
.pipe(helpers.copyMigration('createPerson.js'))
.pipe(helpers.overwriteFile(configContent, 'config/config.js'))
.pipe(helpers.runCli('db:migrate'))
.on('error', function (e) {
callback(e);
})
.on('data', function (data) {
result += data.toString();
})
.on('end', function () {
callback(null, result);
});
};

it('creates a SequelizeMeta table', function (done) {
var self = this;

prepare(function () {
helpers.readTables(self.sequelize, function (tables) {
expect(tables).to.have.length(2);
expect(tables).to.contain('SequelizeMeta');
done();
});
});
});

it('creates the respective table', function (done) {
var self = this;

prepare(function () {
helpers.readTables(self.sequelize, function (tables) {
expect(tables).to.have.length(2);
expect(tables).to.contain('Person');
done();
});
});
});
});
});

describe(Support.getTestDialectTeaser('db:migrate'), function () {
describe('with config.json and url option', function () {
var prepare = function (callback) {
Expand Down

0 comments on commit 61878ee

Please sign in to comment.