From 47a56ccb5a8ca7b4ef945a98e34a336d540c1dbf Mon Sep 17 00:00:00 2001 From: Sander Tolsma Date: Sun, 23 Oct 2011 10:30:51 +0200 Subject: [PATCH] [test] Test for hierarchical argv options get() --- test/fixtures/scripts/hierarchical.json | 3 +++ .../scripts/nconf-hierarchical-file-argv.js | 17 +++++++++++++++++ test/provider-test.js | 5 +++++ 3 files changed, 25 insertions(+) create mode 100644 test/fixtures/scripts/hierarchical.json create mode 100644 test/fixtures/scripts/nconf-hierarchical-file-argv.js diff --git a/test/fixtures/scripts/hierarchical.json b/test/fixtures/scripts/hierarchical.json new file mode 100644 index 0000000..1385be3 --- /dev/null +++ b/test/fixtures/scripts/hierarchical.json @@ -0,0 +1,3 @@ +{ + "test": "empty" +} \ No newline at end of file diff --git a/test/fixtures/scripts/nconf-hierarchical-file-argv.js b/test/fixtures/scripts/nconf-hierarchical-file-argv.js new file mode 100644 index 0000000..7124d90 --- /dev/null +++ b/test/fixtures/scripts/nconf-hierarchical-file-argv.js @@ -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'); \ No newline at end of file diff --git a/test/provider-test.js b/test/provider-test.js index fee27ba..4b592cb 100644 --- a/test/provider-test.js +++ b/test/provider-test.js @@ -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 } }) } }