UNPKG

2.83 kBJavaScriptView Raw
1/*
2 * log-test.js: Tests for vanilla logging with no authentication.
3 *
4 * (C) 2010 Nodejitsu Inc.
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 }),
16 logglyJSON = require('../lib/loggly').createClient({ subdomain: config.subdomain, 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 config.inputs.test.token,
26 'this is a test logging message from /test/input-test.js',
27 this.callback);
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 "when not passed a callback": {
36 topic: function () {
37 var emitter = loggly.log(config.inputs.test.token, 'this is a test logging message from /test/input-test.js');
38 emitter.on('log', this.callback.bind(null, null));
39 },
40 "should log messages to loggly": function (err, result) {
41 assert.isNull(err);
42 assert.isObject(result);
43 assert.equal(result.response, 'ok');
44 }
45 }
46 },
47 "to a 'json' input": {
48 "when passed a callback": {
49 topic: function () {
50 logglyJSON.log(
51 config.inputs.test_json.token,
52 {
53 timestamp: new Date().getTime(),
54 message: 'this is a test logging message from /test/input-test.js'
55 },
56 this.callback);
57 },
58 "should log messages to loggly": function (err, result) {
59 assert.isNull(err);
60 assert.isObject(result);
61 assert.equal(result.response, 'ok');
62 }
63 },
64 "when not passed a callback": {
65 topic: function () {
66 var emitter = logglyJSON.log(
67 config.inputs.test_json.token,
68 {
69 timestamp: new Date().getTime(),
70 message: 'this is a test logging message from /test/input-test.js'
71 }
72 );
73 emitter.on('log', this.callback.bind(null, null));
74 },
75 "should log messages to loggly": function (err, result) {
76 assert.isNull(err);
77 assert.isObject(result);
78 assert.equal(result.response, 'ok');
79 }
80 }
81 }
82 }
83 }
84}).export(module);
\No newline at end of file