Permalink
Browse files

[test] New basic test for jitsu logs

  • Loading branch information...
1 parent df1ebb2 commit de733537519e0fcc3ce253028798a8c3a7aeaadf @jfhbrook jfhbrook committed Feb 28, 2012
Showing with 89 additions and 2 deletions.
  1. +87 −0 test/commands/logs-test.js
  2. +2 −2 test/commands/package-test.js
@@ -0,0 +1,87 @@
+/*
+ * logs-test.js: Tests for `jitsu logs *` commands.
+ *
+ * (C) 2010, Nodejitsu Inc.
+ *
+ */
+
+var nock = require('nock'),
+ assert = require('assert'),
+ vows = require('vows'),
+ path = require('path'),
+ fs = require('fs'),
+ jitsu = require('../../lib/jitsu'),
+ macros = require('../helpers/macros');
+
+var shouldNodejitsuOk = macros.shouldNodejitsuOk,
+ useAppFixture = macros.useAppFixture;
+
+var mainDirectory = process.cwd();
+
+// Snapshots tests with specified app names
+vows.describe('jitsu/commands/logs').addBatch({
+ 'logs': shouldNodejitsuOk(function setup() {
+
+ useAppFixture();
+
+ nock('http://api.mockjitsu.com')
+ .post('/logs/tester/example-app', {
+ from: "NOW-1DAY",
+ until: "NOW",
+ rows: 100
+ })
+ .reply(200, {
+ data: [
+ {
+ isjson: true,
+ timestamp: '2012-12-21T02:00:00.000z',
+ inputid: '5656',
+ json: {
+ app: 'example-app',
+ message: 'This is a message on stderr',
+ level: 'info',
+ event: 'drone:stderr',
+ user: 'jesusabdullah'
+ }
+ },
+ {
+ isjson: true,
+ timestamp: '2012-12-21T01:00:00.000z',
+ inputid: '5656',
+ json: {
+ app: 'example-app',
+ message: 'This is also a message',
+ level: 'info',
+ event: 'drone:stdout',
+ user: 'jesusabdullah'
+ }
+ },
+ {
+ isjson: true,
+ timestamp: '2012-12-21T00:00:00.000z',
+ inputid: '5656',
+ json: {
+ app: 'example-app',
+ message: 'This is a message',
+ level: 'info',
+ event: 'drone:stdout',
+ user: 'jesusabdullah'
+ }
+ },
+
+ ],
+ numFound: 3,
+ context: {
+ rows: '50',
+ from: 'NOW-1DAY',
+ until: 'NOW',
+ start: 0,
+ query: 'json.user:tester AND json.app:example-app',
+ order: 'desc'
+ }
+ }, { 'x-powered-by': 'Nodejitsu' })
+ }, function assertion (err) {
+ process.chdir(mainDirectory);
+ assert.ok(!err);
+ })
+}).export(module);
@@ -21,7 +21,7 @@ vows.describe('jitsu/commands/package').addBatch({
'should create the target tarball',
function (_, err) {
var tmproot = jitsu.config.get('tmproot'),
- targetPackage = path.join(tmproot, 'tester-example-app-0.0.0-2.tgz');
+ targetPackage = path.join(tmproot, 'tester-example-app-0.0.0-1.tgz');
try {
fs.statSync(targetPackage);
@@ -32,7 +32,7 @@ vows.describe('jitsu/commands/package').addBatch({
},
function setup() {
var tmproot = jitsu.config.get('tmproot'),
- targetPackage = path.join(tmproot, 'tester-example-app-0.0.0-2.tgz');
+ targetPackage = path.join(tmproot, 'tester-example-app-0.0.0-1.tgz');
jitsu.argv.noanalyze = true;
jitsu.prompt.override['invite code'] = 'f4387f4';

0 comments on commit de73353

Please sign in to comment.