Skip to content

Commit

Permalink
chore: add test to detect cmdOptions functionality
Browse files Browse the repository at this point in the history
Refers to #560
Refers to #557

Signed-off-by: Tobias Gurtzick <magic@wizardtales.com>
  • Loading branch information
wzrdtales committed Mar 27, 2018
1 parent 527cee2 commit 531c19e
Showing 1 changed file with 30 additions and 10 deletions.
40 changes: 30 additions & 10 deletions test/integration/api_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ lab.experiment('api', function () {
dbmigrate.silence(true);

/**
* We have set force-exit above, this should end up in db-migrate
* executing process.exit on the final callback.
* Process.exit has been overwritten and will finally call validate.
*
* The test validation takes place in validate()
*/
* We have set force-exit above, this should end up in db-migrate
* executing process.exit on the final callback.
* Process.exit has been overwritten and will finally call validate.
*
* The test validation takes place in validate()
*/
dbmigrate.up();

/**
* Final validation after process.exit should have been called.
*/
* Final validation after process.exit should have been called.
*/
function validate () {
Code.expect(called).to.be.true();
done();
Expand All @@ -59,8 +59,8 @@ lab.experiment('api', function () {
}

/**
* Create a migration with the programatic API and overwrite process.exit.
*/
* Create a migration with the programatic API and overwrite process.exit.
*/
function overwriteExit () {
process.exit = function (err) {
var ret = called;
Expand Down Expand Up @@ -110,6 +110,26 @@ lab.experiment('api', function () {
done();
});

lab.test('should load commandline options from options parameter', function (
done
) {
var options = {
cmdOptions: {
'migrations-dir': './test'
}
};

var api = stubApiInstance(true, {}, options);
var actual = api.internals.argv['migrations-dir'];
var expected = options.cmdOptions['migrations-dir'];

delete expected.getCurrent;
delete actual.getCurrent;

Code.expect(actual).to.equal(expected);
done();
});

lab.test(
'should handle all up parameter variations properly',

Expand Down

0 comments on commit 531c19e

Please sign in to comment.