Skip to content

Commit ce28744

Browse files
author
RandomSeeded
committed
test for check
1 parent e2d25db commit ce28744

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/migrator_test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
var Code = require('code');
2+
var Lab = require('lab');
3+
var proxyquire = require('proxyquire').noPreserveCache();
4+
var lab = (exports.lab = Lab.script());
5+
6+
lab.experiment('migrators', function () {
7+
lab.experiment('check', function () {
8+
lab.test('should return the migrations to be run', function (done) {
9+
var completedMigration = {
10+
name: '20180330020329-thisMigrationIsCompleted'
11+
};
12+
var uncompletedMigration = {
13+
name: '20180330020330-thisMigrationIsNotCompleted'
14+
};
15+
var Migrator = proxyquire('../lib/migrator.js', {
16+
'./migration': {
17+
loadFromFilesystem: (migrationsDir, internals, cb) => {
18+
return cb(null, [completedMigration, uncompletedMigration]);
19+
},
20+
loadFromDatabase: (migrationsDir, driver, internals, cb) => {
21+
return cb(null, [completedMigration]);
22+
}
23+
}
24+
});
25+
Migrator.prototype.check(null, function (err, res) {
26+
Code.expect(res.length).to.equal(1);
27+
Code.expect(res[0].name).to.equal(uncompletedMigration.name);
28+
done(err, res);
29+
});
30+
});
31+
});
32+
});

0 commit comments

Comments
 (0)