Skip to content

Commit

Permalink
test for check
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomSeeded committed Apr 4, 2018
1 parent e2d25db commit ce28744
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/migrator_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var Code = require('code');
var Lab = require('lab');
var proxyquire = require('proxyquire').noPreserveCache();
var lab = (exports.lab = Lab.script());

lab.experiment('migrators', function () {
lab.experiment('check', function () {
lab.test('should return the migrations to be run', function (done) {
var completedMigration = {
name: '20180330020329-thisMigrationIsCompleted'
};
var uncompletedMigration = {
name: '20180330020330-thisMigrationIsNotCompleted'
};
var Migrator = proxyquire('../lib/migrator.js', {
'./migration': {
loadFromFilesystem: (migrationsDir, internals, cb) => {
return cb(null, [completedMigration, uncompletedMigration]);
},
loadFromDatabase: (migrationsDir, driver, internals, cb) => {
return cb(null, [completedMigration]);
}
}
});
Migrator.prototype.check(null, function (err, res) {
Code.expect(res.length).to.equal(1);
Code.expect(res[0].name).to.equal(uncompletedMigration.name);
done(err, res);
});
});
});
});

0 comments on commit ce28744

Please sign in to comment.