[test] Test for hierarchical argv options get()

This commit is contained in:
Sander Tolsma 2011-10-23 10:30:51 +02:00 committed by indexzero
parent c3c315d648
commit 47a56ccb5a
3 changed files with 25 additions and 0 deletions

View file

@ -0,0 +1,3 @@
{
"test": "empty"
}

View file

@ -0,0 +1,17 @@
/*
* nconf-hierarchical-file-argv.js: Test fixture for using optimist defaults and a file store with nconf.
*
* (C) 2011, Charlie Robbins
* (C) 2011, Sander Tolsma
*
*/
var path = require('path'),
nconf = require('../../../lib/nconf');
nconf.argv();
nconf.add('file', {
file: path.join(__dirname, 'hierarchical.json')
});
process.stdout.write(nconf.get('something') || 'undefined');

View file

@ -55,6 +55,11 @@ vows.describe('nconf/provider').addBatch({
"when 'argv' is set to true and process.argv is modified": helpers.assertSystemConf({
script: path.join(fixturesDir, 'scripts', 'nconf-change-argv.js'),
argv: ['--something', 'badValue', 'evenWorse', 'OHNOEZ', 'foobar']
}),
"when hierarchical 'argv' get": helpers.assertSystemConf({
script: path.join(fixturesDir, 'scripts', 'nconf-hierarchical-file-argv.js'),
argv: ['--something', 'foobar'],
env: { SOMETHING: true }
})
}
}