2 * input-test.js: Tests for Loggly input requests
4 * (C) 2010 Nodejitsu Inc.
9 var path = require('path'),
10 vows = require('vows'),
11 assert = require('assert'),
12 helpers = require('./helpers');
16 config = helpers.loadConfig(),
17 loggly = require('../lib/loggly').createClient(config);
19 vows.describe('node-loggly/search').addBatch({
20 "When using the node-loggly client": {
21 "the search() method": {
22 "when searching without chaining": {
24 loggly.search('logging message', this.callback);
26 "should return a set of valid search results": function (err, results) {
27 helpers.assertSearch(err, results);
30 "when searching with chaining": {
32 loggly.search('logging message')
33 .meta({ inputname: 'test' })
36 "should return a set of valid search results": function (err, results) {
37 helpers.assertSearch(err, results);
41 "the facet() method": {
42 "when searching by ip": {
44 loggly.facet('ip', 'test', this.callback);
46 "should return a set of valid search results": function (err, results) {
47 helpers.assertSearch(err, results);
50 "when using chained searches": {
52 loggly.facet('ip', 'test')
53 .context({ from: 'NOW-1MONTH' })
56 "should return a set of valid search results": function (err, results) {
57 helpers.assertSearch(err, results);
61 "the _checkRange() method": {
62 "with invalid options set": {
63 "should correct them": function () {
64 var search = loggly.search('logging message')
65 .context({ from: 'NOW', until: '1DAY' })
68 assert.equal(search._context.from, 'NOW-24HOURS');
69 assert.equal(search._context.until, 'NOW');
72 "with valid options set": {
73 "should not modify them": function () {
74 var search = loggly.search('logging message')
75 .context({ from: 'NOW-2MONTHS', until: 'NOW' })
78 assert.equal(search._context.from, 'NOW-2MONTHS');
79 assert.equal(search._context.until, 'NOW');