diff --git a/test/fixtures/hierarchy/global.json b/test/fixtures/hierarchy/global.json new file mode 100644 index 0000000..4ac5a6e --- /dev/null +++ b/test/fixtures/hierarchy/global.json @@ -0,0 +1,5 @@ +{ + "title": "My generic title", + "color": "red", + "movie": "Kill Bill" +} \ No newline at end of file diff --git a/test/fixtures/hierarchy/user.json b/test/fixtures/hierarchy/user.json new file mode 100644 index 0000000..45a3aac --- /dev/null +++ b/test/fixtures/hierarchy/user.json @@ -0,0 +1,4 @@ +{ + "title": "My specific title", + "color": "green" +} \ No newline at end of file diff --git a/test/hierarchy-test.js b/test/hierarchy-test.js new file mode 100644 index 0000000..b899d3a --- /dev/null +++ b/test/hierarchy-test.js @@ -0,0 +1,33 @@ +/* + * hierarchy-test.js: Basic tests for hierarchical file stores. + * + * (C) 2011, Charlie Robbins + * + */ + +var assert = require('assert'), + path = require('path'), + vows = require('vows'), + nconf = require('../lib/nconf'); + +var configDir = path.join(__dirname, 'fixtures', 'hierarchy'), + globalConfig = path.join(configDir, 'global.json'), + userConfig = path.join(configDir, 'user.json'); + +vows.describe('nconf/hierarchy').addBatch({ + "When using nconf": { + "configured with two file stores": { + topic: function () { + nconf.add('user', { type: 'file', file: userConfig }) + nconf.add('global', { type: 'file', file: globalConfig }) + nconf.load(); + return nconf; + }, + "should have the appropriate keys present": function () { + assert.equal(nconf.get('title'), 'My specific title'); + assert.equal(nconf.get('color'), 'green'); + assert.equal(nconf.get('movie'), 'Kill Bill'); + } + } + } +}).export(module); \ No newline at end of file