c7557f54cbd536addb0400823b4e7dc0c276c919.svn-base
2.76 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
* log-test.js: Tests for vanilla logging with no authentication.
*
* (C) 2010 Nodejitsu Inc.
* MIT LICENSE
*
*/
var path = require('path'),
vows = require('vows'),
assert = require('assert'),
helpers = require('./helpers');
var config = helpers.loadConfig(),
loggly = require('../lib/loggly').createClient({ subdomain: config.subdomain }),
logglyJSON = require('../lib/loggly').createClient({ subdomain: config.subdomain, json: true });
vows.describe('node-loggly/inputs (no auth)').addBatch({
"When using the node-loggly client without authentication": {
"the log() method": {
"to a 'text' input": {
"when passed a callback": {
topic: function () {
loggly.log(
config.inputs.test.token,
'this is a test logging message from /test/input-test.js',
this.callback);
},
"should log messages to loggly": function (err, result) {
assert.isNull(err);
assert.isObject(result);
assert.equal(result.response, 'ok');
}
},
"when not passed a callback": {
topic: function () {
var emitter = loggly.log(config.inputs.test.token, 'this is a test logging message from /test/input-test.js');
emitter.on('log', this.callback.bind(null, null));
},
"should log messages to loggly": function (err, result) {
assert.isNull(err);
assert.isObject(result);
assert.equal(result.response, 'ok');
}
}
},
"to a 'json' input": {
"when passed a callback": {
topic: function () {
logglyJSON.log(
config.inputs.test_json.token,
{
timestamp: new Date().getTime(),
message: 'this is a test logging message from /test/input-test.js'
},
this.callback);
},
"should log messages to loggly": function (err, result) {
assert.isNull(err);
assert.isObject(result);
assert.equal(result.response, 'ok');
}
},
"when not passed a callback": {
topic: function () {
var emitter = logglyJSON.log(
config.inputs.test_json.token,
{
timestamp: new Date().getTime(),
message: 'this is a test logging message from /test/input-test.js'
}
);
emitter.on('log', this.callback.bind(null, null));
},
"should log messages to loggly": function (err, result) {
assert.isNull(err);
assert.isObject(result);
assert.equal(result.response, 'ok');
}
}
}
}
}
}).export(module);