Skip to content
Browse files

handle null config paths on config handler

  • Loading branch information...
1 parent e11539c commit d5eb71d263a0ca969a9197b12b0fd5c6a35bb314 @laktek committed Mar 18, 2013
Showing with 11 additions and 0 deletions.
  1. +4 −0 lib/config_handler.js
  2. +7 −0 spec/config_handler.spec.js
View
4 lib/config_handler.js
@@ -47,6 +47,10 @@ module.exports = {
var self = this;
var combined_config = {};
+ if (!config_path) {
+ return callback("config path can't be null", null);
+ }
+
fs.readdir(config_path, function(err, files){
if(err) {
return callback(err, null);
View
7 spec/config_handler.spec.js
@@ -110,6 +110,13 @@ describe("read the config form a file", function() {
describe("read the config from a directory", function() {
+ it("call the callback with the error if config path is null", function() {
+ var spyCallback = jasmine.createSpy();
+ config_handler.readConfigDir(null, spyCallback);
+
+ expect(spyCallback).toHaveBeenCalledWith("config path can't be null", null);
+ });
+
it("fetch all files in the given directory", function() {
spyOn(fs, "readdir");

0 comments on commit d5eb71d

Please sign in to comment.
Something went wrong with that request. Please try again.