fixed file appender tests

date-rolling-file-appender
Gareth Jones 13 years ago
parent 352653dcbe
commit c8157cef5c

@ -27,11 +27,11 @@
},
"dependencies": {
"async": "0.1.15",
"compress-buffer": ">= 0.5.0"
"compress-buffer": "0.5.1"
},
"devDependencies": {
"vows": ">=0.5.2",
"sandboxed-module": ">= 0.1.1",
"vows": "0.6.2",
"sandboxed-module": "0.1.3",
"hook.io": "0.7.7",
"underscore": "1.2.1"
}

@ -1,5 +1,6 @@
var vows = require('vows')
, fs = require('fs')
, path = require('path')
, log4js = require('../lib/log4js')
, assert = require('assert');
@ -17,7 +18,8 @@ vows.describe('log4js fileAppender').addBatch({
'with default fileAppender settings': {
topic: function() {
var that = this, testFile = __dirname + '/fa-default-test.log'
var that = this
, testFile = path.join(__dirname, '/fa-default-test.log')
, logger = log4js.getLogger('default-settings');
remove(testFile);
log4js.clearAppenders();
@ -38,7 +40,7 @@ vows.describe('log4js fileAppender').addBatch({
},
'with a max file size and no backups': {
topic: function() {
var testFile = __dirname + '/fa-maxFileSize-test.log'
var testFile = path.join(__dirname, '/fa-maxFileSize-test.log')
, logger = log4js.getLogger('max-file-size')
, that = this;
remove(testFile);
@ -71,7 +73,7 @@ vows.describe('log4js fileAppender').addBatch({
},
'with a max file size and 2 backups': {
topic: function() {
var testFile = __dirname + '/fa-maxFileSize-with-backups-test.log'
var testFile = path.join(__dirname, '/fa-maxFileSize-with-backups-test.log')
, logger = log4js.getLogger('max-file-size-backups');
remove(testFile);
remove(testFile+'.1');
@ -103,26 +105,26 @@ vows.describe('log4js fileAppender').addBatch({
},
'and the contents of the first file': {
topic: function(logFiles) {
fs.readFile(logFiles[0], "utf8", this.callback);
fs.readFile(path.join(__dirname, logFiles[0]), "utf8", this.callback);
},
'should be the last log message': function(err, contents) {
assert.include(contents, 'This is the fourth log message.');
'should be empty because the last log message triggers rolling': function(contents) {
assert.isEmpty(contents);
}
},
'and the contents of the second file': {
topic: function(logFiles) {
fs.readFile(logFiles[1], "utf8", this.callback);
fs.readFile(path.join(__dirname, logFiles[1]), "utf8", this.callback);
},
'should be the third log message': function(err, contents) {
assert.include(contents, 'This is the third log message.');
'should be the last log message': function(contents) {
assert.include(contents, 'This is the fourth log message.');
}
},
'and the contents of the third file': {
topic: function(logFiles) {
fs.readFile(logFiles[2], "utf8", this.callback);
fs.readFile(path.join(__dirname, logFiles[2]), "utf8", this.callback);
},
'should be the second log message': function(err, contents) {
assert.include(contents, 'This is the second log message.');
'should be the third log message': function(contents) {
assert.include(contents, 'This is the third log message.');
}
}
}

Loading…
Cancel
Save