-
-
Notifications
You must be signed in to change notification settings - Fork 358
/
migrator_test.js
32 lines (31 loc) · 1.1 KB
/
migrator_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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);
});
});
});
});