UNPKG

5.29 kBJavaScriptView Raw
1/*
2 * log-test.js: Tests for vanilla logging with no authentication.
3 *
4 * (C) 2010 Charlie Robbins
5 * MIT LICENSE
6 *
7 */
8
9var path = require('path'),
10 vows = require('vows'),
11 assert = require('assert'),
12 helpers = require('./helpers');
13
14var config = helpers.loadConfig(),
15 loggly = require('../lib/loggly').createClient({ subdomain: config.subdomain, token: config.token }),
16 logglyJSON = require('../lib/loggly').createClient({ subdomain: config.subdomain, token: config.token, json: true });
17
18vows.describe('node-loggly/inputs (no auth)').addBatch({
19 "When using the node-loggly client without authentication": {
20 "the log() method": {
21 "to a 'text' input": {
22 "when passed a callback": {
23 topic: function () {
24 loggly.log(
25 'this is a test logging message from /test/input-test.js',
26 this.callback
27 );
28 },
29 "should log messages to loggly": function (err, result) {
30 assert.isNull(err);
31 assert.isObject(result);
32 assert.equal(result.response, 'ok');
33 }
34 },
35 }
36 }
37 }
38})
39.addBatch({
40 "When using the node-loggly client without authentication": {
41 "the log() method": {
42 "to a 'text' input": {
43 "when not passed a callback": {
44 topic: function () {
45 loggly.log('this is a test logging message from /test/input-test.js');
46 loggly.on('log', this.callback.bind(null, null));
47 },
48 "should log messages to loggly": function (err, result) {
49 assert.isNull(err);
50 assert.isObject(result);
51 assert.equal(result.response, 'ok');
52 }
53 }
54 },
55 }
56 }
57})
58.addBatch({
59 "When using the node-loggly client without authentication": {
60 "the log() method": {
61 "to a 'json' input": {
62 "when passed a callback": {
63 topic: function () {
64 logglyJSON.log({
65 timestamp: new Date().getTime(),
66 message: 'this is a test logging message from /test/input-test.js'
67 }, this.callback);
68 },
69 "should log messages to loggly": function (err, result) {
70 assert.isNull(err);
71 assert.isObject(result);
72 assert.equal(result.response, 'ok');
73 }
74 }
75 }
76 }
77 }
78})
79.addBatch({
80 "When using the node-loggly client without authentication": {
81 "the log() method": {
82 "to a 'json' input": {
83 "when not passed a callback": {
84 topic: function () {
85 logglyJSON.log({
86 timestamp: new Date().getTime(),
87 message: 'this is a test logging message from /test/input-test.js'
88 });
89 logglyJSON.on('log', this.callback.bind(null, null));
90 },
91 "should log messages to loggly": function (err, result) {
92 assert.isNull(err);
93 assert.isObject(result);
94 assert.equal(result.response, 'ok');
95 }
96 }
97 }
98 }
99 }
100}).addBatch({
101 "When using the node-loggly client without authentication": {
102 "the log() method": {
103 "to a 'json' input with a single tag": {
104 "when not passed a callback": {
105 topic: function () {
106 logglyJSON.log({
107 timestamp: new Date().getTime(),
108 message: 'this is a test logging message from /test/input-test.js'
109 }, "WOOOO-TAG");
110 logglyJSON.on('log', this.callback.bind(null, null));
111 },
112 "should log messages to loggly": function (err, result) {
113 assert.isNull(err);
114 assert.isObject(result);
115 assert.equal(result.response, 'ok');
116 }
117 }
118 }
119 }
120 }
121}).addBatch({
122 "When using the node-loggly client without authentication": {
123 "the log() method": {
124 "to a 'json' input with tags that exist as an array": {
125 "when not passed a callback": {
126 topic: function () {
127 logglyJSON.log({
128 timestamp: new Date().getTime(),
129 message: 'this is a test logging message from /test/input-test.js'
130 }, ["tag", "tag2"]);
131 logglyJSON.on('log', this.callback.bind(null, null));
132 },
133 "should log messages to loggly": function (err, result) {
134 assert.isNull(err);
135 assert.isObject(result);
136 assert.equal(result.response, 'ok');
137 }
138 }
139 }
140 }
141 }
142}).addBatch({
143 "When using the node-loggly client without authentication": {
144 "the log() method": {
145 "takes an array": {
146 "when not passed a callback": {
147 topic: function () {
148 logglyJSON.log([
149 { work: 'it harder' },
150 { make: 'it better' }
151 ]);
152 logglyJSON.on('log', this.callback.bind(null, null));
153 },
154 "should log messages to loggly": function (err, result) {
155 assert.isNull(err);
156 assert.isObject(result);
157 assert.equal(result.response, 'ok');
158 }
159 }
160 }
161 }
162 }
163}).export(module);