a1ac8bac765a906b09a5baf44102942ddc381505.svn-base
1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* loggly-test.js: Tests for instances of the Loggly transport
*
* (C) 2010 Charlie Robbins
* MIT LICENSE
*
*/
var path = require('path'),
vows = require('vows'),
assert = require('assert'),
winston = require('../../lib/winston'),
helpers = require('../helpers');
var config = helpers.loadConfig();
if (!config) {
return;
}
var tokenTransport = new (winston.transports.Loggly)({
subdomain: config.transports.loggly.subdomain,
inputToken: config.transports.loggly.inputToken
}),
nameTransport = new (winston.transports.Loggly)({
subdomain: config.transports.loggly.subdomain,
inputName: config.transports.loggly.inputName,
auth: config.transports.loggly.auth
});
vows.describe('winston/transports/loggly').addBatch({
"An instance of the Loggly Transport": {
"when passed an input token": {
"should have the proper methods defined": function () {
helpers.assertLoggly(tokenTransport);
},
"the log() method": helpers.testNpmLevels(tokenTransport, "should log messages to loggly", function (ign, err, logged) {
assert.isNull(err);
assert.isTrue(logged);
}),
"the log() method with no metadata": {
topic: function () {
tokenTransport.log('info', 'test-message', null, this.callback.bind(null, null));
},
"should respond immediately": function () {
assert.isTrue(true);
}
}
},
"when passed an input name": {
"should have the proper methods defined": function () {
helpers.assertLoggly(nameTransport);
},
"the log() method": helpers.testNpmLevels(nameTransport, "should log messages to loggly", function (ign, err, result) {
assert.isNull(err);
assert.isTrue(result === true || result.response === 'ok');
})
}
}
}).export(module);