Fixes bug in detecting empty options (see issue #132 on github)

This commit is contained in:
Issac Goldstand 2013-05-08 12:05:32 +03:00
parent 936ad4da8e
commit 8c12c948d9
2 changed files with 5 additions and 1 deletions

View File

@ -30,7 +30,7 @@ function DateRollingFileStream(filename, pattern, options, now) {
filename = filename + this.lastTimeWeWroteSomething; filename = filename + this.lastTimeWeWroteSomething;
} }
delete options.alwaysIncludePattern; delete options.alwaysIncludePattern;
if (options === {}) { if (Object.keys(options).length === 0) {
options = null; options = null;
} }
} }

View File

@ -113,6 +113,7 @@ vows.describe('../lib/appenders/dateFile').addBatch({
] ]
} }
, thisTime = format.asString(options.appenders[0].pattern, new Date()); , thisTime = format.asString(options.appenders[0].pattern, new Date());
fs.writeFileSync(path.join(__dirname, 'date-file-test' + thisTime), "this is existing data" + require('os').EOL, 'utf8');
log4js.clearAppenders(); log4js.clearAppenders();
log4js.configure(options); log4js.configure(options);
logger = log4js.getLogger('tests'); logger = log4js.getLogger('tests');
@ -122,6 +123,9 @@ vows.describe('../lib/appenders/dateFile').addBatch({
}, },
'should create file with the correct pattern': function(contents) { 'should create file with the correct pattern': function(contents) {
assert.include(contents, 'this should be written to the file with the appended date'); assert.include(contents, 'this should be written to the file with the appended date');
},
'should not overwrite the file on open (bug found in issue #132)': function(contents) {
assert.include(contents, 'this is existing data');
} }
} }