moved streams code around, added stub for DateRollingFileStream

This commit is contained in:
Gareth Jones
2012-09-05 10:58:28 +10:00
parent cbc1dd32f9
commit be1272cd7c
9 changed files with 349 additions and 271 deletions

View File

@@ -0,0 +1,49 @@
var vows = require('vows'),
assert = require('assert'),
fs = require('fs'),
DateRollingFileStream = require('../../lib/streams').DateRollingFileStream;
vows.describe('DateRollingFileStream').addBatch({
'arguments': {
topic: new DateRollingFileStream('test-date-rolling-file-stream', 'yyyy-mm-dd.hh'),
'should take a filename and a pattern and return a FileWriteStream': function(stream) {
assert.equal(stream.filename, 'test-date-rolling-file-stream');
assert.equal(stream.pattern, 'yyyy-mm-dd.hh');
assert.instanceOf(stream, fs.FileWriteStream);
},
'with default settings for the underlying stream': function(stream) {
assert.equal(stream.mode, 420);
assert.equal(stream.flags, 'a');
assert.equal(stream.encoding, 'utf8');
}
},
'default arguments': {
topic: new DateRollingFileStream('test-date-rolling-file-stream'),
'pattern should be yyyy-mm-dd': function(stream) {
assert.equal(stream.pattern, 'yyyy-mm-dd');
}
},
'with stream arguments': {
topic: new DateRollingFileStream('test-rolling-file-stream', 'yyyy-mm-dd', { mode: 0666 }),
'should pass them to the underlying stream': function(stream) {
assert.equal(stream.mode, 0666);
}
},
'with stream arguments but no pattern': {
topic: new DateRollingFileStream('test-rolling-file-stream', { mode: 0666 }),
'should pass them to the underlying stream': function(stream) {
assert.equal(stream.mode, 0666);
},
'should use default pattern': function(stream) {
assert.equal(stream.pattern, 'yyyy-mm-dd');
}
}
}).exportTo(module);

View File

@@ -1,7 +1,7 @@
var vows = require('vows')
, assert = require('assert')
, events = require('events')
, BufferedWriteStream = require('../lib/streams').BufferedWriteStream;
, BufferedWriteStream = require('../../lib/streams').BufferedWriteStream;
function FakeStream() {
this.writes = [];
@@ -127,4 +127,4 @@ vows.describe('BufferedWriteStream').addBatch({
}
}
}).exportTo(module);
}).exportTo(module);

View File

@@ -2,7 +2,7 @@ var vows = require('vows')
, assert = require('assert')
, events = require('events')
, fs = require('fs')
, RollingFileStream = require('../lib/streams').RollingFileStream;
, RollingFileStream = require('../../lib/streams').RollingFileStream;
function remove(filename) {
try {