Skip to content

Commit 531c19e

Browse files
committed
chore: add test to detect cmdOptions functionality
Refers to #560 Refers to #557 Signed-off-by: Tobias Gurtzick <[email protected]>
1 parent 527cee2 commit 531c19e

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

test/integration/api_test.js

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,17 @@ lab.experiment('api', function () {
3131
dbmigrate.silence(true);
3232

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

4242
/**
43-
* Final validation after process.exit should have been called.
44-
*/
43+
* Final validation after process.exit should have been called.
44+
*/
4545
function validate () {
4646
Code.expect(called).to.be.true();
4747
done();
@@ -59,8 +59,8 @@ lab.experiment('api', function () {
5959
}
6060

6161
/**
62-
* Create a migration with the programatic API and overwrite process.exit.
63-
*/
62+
* Create a migration with the programatic API and overwrite process.exit.
63+
*/
6464
function overwriteExit () {
6565
process.exit = function (err) {
6666
var ret = called;
@@ -110,6 +110,26 @@ lab.experiment('api', function () {
110110
done();
111111
});
112112

113+
lab.test('should load commandline options from options parameter', function (
114+
done
115+
) {
116+
var options = {
117+
cmdOptions: {
118+
'migrations-dir': './test'
119+
}
120+
};
121+
122+
var api = stubApiInstance(true, {}, options);
123+
var actual = api.internals.argv['migrations-dir'];
124+
var expected = options.cmdOptions['migrations-dir'];
125+
126+
delete expected.getCurrent;
127+
delete actual.getCurrent;
128+
129+
Code.expect(actual).to.equal(expected);
130+
done();
131+
});
132+
113133
lab.test(
114134
'should handle all up parameter variations properly',
115135

0 commit comments

Comments
 (0)