2 var vows = require('vows')
3 , assert = require('assert')
5 , sandbox = require('sandboxed-module');
7 vows.describe('../../lib/streams/BaseRollingFileStream').addBatch({
8 'when node version < 0.10.0': {
10 var streamLib = sandbox.load(
11 '../../lib/streams/BaseRollingFileStream',
20 Writable: function() {}
25 return streamLib.required;
27 'it should use readable-stream to maintain compatibility': function(required) {
28 assert.ok(required['readable-stream']);
29 assert.ok(!required.stream);
33 'when node version > 0.10.0': {
35 var streamLib = sandbox.load(
36 '../../lib/streams/BaseRollingFileStream',
45 Writable: function() {}
50 return streamLib.required;
52 'it should use the core stream module': function(required) {
53 assert.ok(required.stream);
54 assert.ok(!required['readable-stream']);
58 'when no filename is passed': {
59 topic: require('../../lib/streams/BaseRollingFileStream'),
60 'it should throw an error': function(BaseRollingFileStream) {
62 new BaseRollingFileStream();
63 assert.fail('should not get here');
70 'default behaviour': {
72 var BaseRollingFileStream = require('../../lib/streams/BaseRollingFileStream')
73 , stream = new BaseRollingFileStream('basetest.log');
76 teardown: function() {
78 fs.unlink('basetest.log');
80 console.error("could not remove basetest.log", e);
83 'it should not want to roll': function(stream) {
84 assert.isFalse(stream.shouldRoll());
86 'it should not roll': function(stream) {
88 //just calls the callback straight away, no async calls
89 stream.roll('basetest.log', function() { cbCalled = true; });
90 assert.isTrue(cbCalled);