e9e1b3542a1b8fd6dbe9e1ba9d3dad8283d98a97.svn-base
2.53 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
/*
* input-test.js: Tests for Loggly input requests
*
* (C) 2010 Nodejitsu Inc.
* MIT LICENSE
*
*/
var path = require('path'),
vows = require('vows'),
assert = require('assert'),
helpers = require('./helpers');
var options = {},
testContext = {},
config = helpers.loadConfig(),
loggly = require('../lib/loggly').createClient(config);
vows.describe('node-loggly/search').addBatch({
"When using the node-loggly client": {
"the search() method": {
"when searching without chaining": {
topic: function () {
loggly.search('logging message', this.callback);
},
"should return a set of valid search results": function (err, results) {
helpers.assertSearch(err, results);
}
},
"when searching with chaining": {
topic: function () {
loggly.search('logging message')
.meta({ inputname: 'test' })
.run(this.callback);
},
"should return a set of valid search results": function (err, results) {
helpers.assertSearch(err, results);
}
}
},
"the facet() method": {
"when searching by ip": {
topic: function () {
loggly.facet('ip', 'test', this.callback);
},
"should return a set of valid search results": function (err, results) {
helpers.assertSearch(err, results);
}
},
"when using chained searches": {
topic: function () {
loggly.facet('ip', 'test')
.context({ from: 'NOW-1MONTH' })
.run(this.callback);
},
"should return a set of valid search results": function (err, results) {
helpers.assertSearch(err, results);
}
}
},
"the _checkRange() method": {
"with invalid options set": {
"should correct them": function () {
var search = loggly.search('logging message')
.context({ from: 'NOW', until: '1DAY' })
._checkRange();
assert.equal(search._context.from, 'NOW-24HOURS');
assert.equal(search._context.until, 'NOW');
}
},
"with valid options set": {
"should not modify them": function () {
var search = loggly.search('logging message')
.context({ from: 'NOW-2MONTHS', until: 'NOW' })
._checkRange();
assert.equal(search._context.from, 'NOW-2MONTHS');
assert.equal(search._context.until, 'NOW');
}
}
}
}
}).export(module);