Skip to content

Config null check #198

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ exports.load = function(fileName, currentEnv) {
//Check config entry's for ENV objects
//which will tell us to grab configuration from the environment
for (var configEntry in config[env]) {
if (config[env][configEntry].ENV != null){
if (config[env][configEntry] && config[env][configEntry].ENV != null){
config[env][configEntry] = process.env[config[env][configEntry].ENV];
}
}
Expand Down
19 changes: 18 additions & 1 deletion test/config_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,22 @@ vows.describe('config').addBatch({
assert.equal(current.settings.database, 'dbname');
}
}
}).export(module);
}).addBatch({
'loading a config with null values': {
topic: function() {
var configPath = path.join(__dirname, 'database_with_null_values.json');
config.load = _configLoad;
config.loadUrl = _configLoadUrl;
try {
config.load(configPath, 'dev');
}catch(e) {
return e;
}
return null;
},

'should something': function(err) {
assert.isNull(err);
}
}
}).export(module);
16 changes: 16 additions & 0 deletions test/database_with_null_values.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"dev": {
"driver": null,
"filename": ":memory:"
},

"test": {
"driver": null,
"filename": ":memory:"
},

"prod": {
"driver": null,
"filename": "prod.db"
}
}