Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed a bug where changes to module defaults arent persisted

  • Loading branch information...
commit e5d0f49dfed732b9209c6a2d9d0fac747aeb92de 1 parent e9dcec5
Loren West authored
View
6 History.md
@@ -1,3 +1,9 @@
+0.4.8 / 2011-12-20
+==================
+
+ * Fixed a bug where changes to module default configs weren't persisted
+ * Added a test to validate the bugfix
+
0.4.7 / 2011-12-16
==================
View
6 lib/config.js
@@ -284,11 +284,11 @@ Config.prototype.setModuleDefaults = function(moduleName, defaultProperties) {
// Extend the module config object with values from originalConfig
if (originalConfig[moduleName]) {
t._extendDeep(moduleConfig, originalConfig[moduleName]);
-
- // Save the mixed module config as the original
- originalConfig[moduleName] = moduleConfig;
}
+ // Save the mixed module config as the original
+ originalConfig[moduleName] = t._cloneDeep(moduleConfig);
+
// Extend the module config object with values from runtimeJson
if (runtimeJson[moduleName]) {
t._extendDeep(moduleConfig, runtimeJson[moduleName]);
View
2  package.json
@@ -1,6 +1,6 @@
{
"name": "config",
- "version": "0.4.7",
+ "version": "0.4.8",
"main": "./lib/config.js",
"description": "Configuration control for production node deployments",
"author": "Loren West <open_source@lorenwest.com>",
View
11 test/2-config-test.js
@@ -111,7 +111,7 @@ exports.ConfigTest = vows.describe('Test suite for node-config').addBatch({
// Set some parameters for the test module
return CONFIG.setModuleDefaults("TestModule", {
- parm1: 1000, parm2: 2000
+ parm1: 1000, parm2: 2000, parm3: 3000
});
},
@@ -131,6 +131,7 @@ exports.ConfigTest = vows.describe('Test suite for node-config').addBatch({
'Defaults remain intact unless overridden': function(moduleConfig) {
assert.equal(moduleConfig.parm2, 2000);
}
+
},
'Internal Change Notification Tests': {
@@ -139,11 +140,16 @@ exports.ConfigTest = vows.describe('Test suite for node-config').addBatch({
// Attach this topic as a watcher
var cb = this.callback;
CONFIG.watch(CONFIG, null, function(obj, prop, oldValue, newValue){
+ // Don't process the submodule test - that's for later
+ if (prop == 'parm3') return;
cb(null, {obj:obj, prop:prop, oldValue:oldValue, newValue:newValue});
});
// Write the new watched value out to the runtime.json file
CONFIG.watchThisValue = newWatchedValue;
+
+ // Test that submodule configurations are persisted
+ CONFIG.TestModule.parm3 = 1234;
},
'The watch() method is available': function() {
@@ -197,6 +203,9 @@ exports.ConfigTest = vows.describe('Test suite for node-config').addBatch({
},
'Changed configuration values were persisted': function(err, runtimeObj) {
assert.equal(runtimeObj.watchThisValue, CONFIG.watchThisValue);
+ },
+ 'Module default values are persisted': function(err, runtimeObj) {
+ assert.equal(runtimeObj.TestModule.parm3, 1234);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.