You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
log4js-node/test/log-abspath-test.js

78 lines
1.9 KiB

11 years ago
"use strict";
var vows = require('vows')
, assert = require('assert')
, path = require('path')
, sandbox = require('sandboxed-module');
vows.describe('log4js-abspath').addBatch({
11 years ago
'options': {
topic: function() {
var appenderOptions,
log4js = sandbox.require(
'../lib/log4js',
{ requires:
{ './appenders/fake':
{ name: "fake",
appender: function() {},
configure: function(configuration, options) {
appenderOptions = options;
return function() {};
}
}
}
}
11 years ago
),
config = {
"appenders": [
{
"type" : "fake",
"filename" : "cheesy-wotsits.log"
}
]
};
log4js.configure(config, {
cwd: '/absolute/path/to'
});
return appenderOptions;
},
11 years ago
'should be passed to appenders during configuration': function(options) {
assert.equal(options.cwd, '/absolute/path/to');
}
},
11 years ago
'file appender': {
topic: function() {
var fileOpened,
fileAppender = sandbox.require(
'../lib/appenders/file',
{ requires:
{ '../streams':
{ RollingFileStream:
function(file) {
fileOpened = file;
return {
on: function() {},
end: function() {}
};
}
}
}
}
11 years ago
);
fileAppender.configure(
{
filename: "whatever.log",
maxLogSize: 10
},
{ cwd: '/absolute/path/to' }
);
return fileOpened;
},
11 years ago
'should prepend options.cwd to config.filename': function(fileOpened) {
var expected = path.sep + path.join("absolute", "path", "to", "whatever.log");
assert.equal(fileOpened, expected);
11 years ago
}
},
}).export(module);