-
-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
RandomSeeded
committed
Apr 4, 2018
1 parent
e2d25db
commit ce28744
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
}); | ||
}); |