Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50675 views
1
/*
2
* file-test.js: Tests for instances of the File transport
3
*
4
* (C) 2010 Charlie Robbins
5
* MIT LICENSE
6
*
7
*/
8
9
var path = require('path'),
10
vows = require('vows'),
11
fs = require('fs'),
12
assert = require('assert'),
13
winston = require('../../lib/winston'),
14
helpers = require('../helpers');
15
16
var transport = require('./transport');
17
18
var stream = fs.createWriteStream(
19
path.join(__dirname, '..', 'fixtures', 'logs', 'testfile.log')
20
),
21
fileTransport = new (winston.transports.File)({
22
filename: path.join(__dirname, '..', 'fixtures', 'logs', 'testfilename.log')
23
}),
24
streamTransport = new (winston.transports.File)({ stream: stream });
25
26
vows.describe('winston/transports/file').addBatch({
27
"An instance of the File Transport": {
28
"when passed a valid filename": {
29
"should have the proper methods defined": function () {
30
helpers.assertFile(fileTransport);
31
},
32
"the log() method": helpers.testNpmLevels(fileTransport, "should respond with true", function (ign, err, logged) {
33
assert.isNull(err);
34
assert.isTrue(logged);
35
})
36
},
37
"when passed a valid file stream": {
38
"should have the proper methods defined": function () {
39
helpers.assertFile(streamTransport);
40
},
41
"the log() method": helpers.testNpmLevels(streamTransport, "should respond with true", function (ign, err, logged) {
42
assert.isNull(err);
43
assert.isTrue(logged);
44
})
45
}
46
}
47
}).addBatch({
48
"These tests have a non-deterministic end": {
49
topic: function () {
50
setTimeout(this.callback, 200);
51
},
52
"and this should be fixed before releasing": function () {
53
assert.isTrue(true);
54
}
55
}
56
}).addBatch({
57
"An instance of the File Transport": transport(winston.transports.File, {
58
filename: path.join(__dirname, '..', 'fixtures', 'logs', 'testfile.log')
59
})
60
}).export(module);
61
62