[test] Test command line arguments reparsing
This commit is contained in:
parent
bbc5885fc1
commit
2475d06cb2
2 changed files with 24 additions and 1 deletions
18
test/fixtures/scripts/nconf-change-argv.js
vendored
Normal file
18
test/fixtures/scripts/nconf-change-argv.js
vendored
Normal 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'));
|
||||||
|
|
|
@ -51,6 +51,10 @@ vows.describe('nconf/provider').addBatch({
|
||||||
"when 'env' is set to true": helpers.assertSystemConf({
|
"when 'env' is set to true": helpers.assertSystemConf({
|
||||||
script: path.join(fixturesDir, 'scripts', 'nconf-env.js'),
|
script: path.join(fixturesDir, 'scripts', 'nconf-env.js'),
|
||||||
env: { SOMETHING: 'foobar' }
|
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']
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,4 +88,5 @@ vows.describe('nconf/provider').addBatch({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).export(module);
|
}).export(module);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue