[test] Test command line arguments reparsing

This commit is contained in:
Maciej Małecki 2011-11-19 02:02:22 +01:00
parent bbc5885fc1
commit 2475d06cb2
2 changed files with 24 additions and 1 deletions

View file

@ -0,0 +1,18 @@
/*
* nconf-change-argv.js: Test fixture for changing argv on the fly
*
* (C) 2011, Charlie Robbins
*
*/
var nconf = require('../../../lib/nconf');
nconf.argv = true;
//
// Remove 'badValue', 'evenWorse' and 'OHNOEZ'
//
process.argv.splice(3, 3);
nconf.system.loadArgv();
process.stdout.write(nconf.get('something'));

View file

@ -51,6 +51,10 @@ vows.describe('nconf/provider').addBatch({
"when 'env' is set to true": helpers.assertSystemConf({
script: path.join(fixturesDir, 'scripts', 'nconf-env.js'),
env: { SOMETHING: 'foobar' }
}),
"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']
})
}
}
@ -85,3 +89,4 @@ vows.describe('nconf/provider').addBatch({
}
}
}).export(module);