Browse files

[test] Testing `snapshots list` without a specified app.

  • Loading branch information...
1 parent a9a845c commit 398a5ce8fae462d3d8154e540ae20d4273003038 @jfhbrook jfhbrook committed Feb 23, 2012
Showing with 33 additions and 1 deletion.
  1. +33 −1 test/commands/snapshots-test.js
View
34 test/commands/snapshots-test.js
@@ -7,12 +7,15 @@
var nock = require('nock'),
vows = require('vows'),
+ path = require('path'),
+ fs = require('fs'),
jitsu = require('../../lib/jitsu'),
macros = require('../helpers/macros');
var shouldNodejitsuOk = macros.shouldNodejitsuOk;
-vows.describe('jitsu/commans/snapshots').addBatch({
+// Snapshots tests with specified app names
+vows.describe('jitsu/commands/snapshots').addBatch({
'snapshots list application': shouldNodejitsuOk(function setup() {
nock('http://api.mockjitsu.com')
.get('/apps/tester/application/snapshots')
@@ -70,4 +73,33 @@ vows.describe('jitsu/commans/snapshots').addBatch({
.delete('/apps/tester/application3/snapshots/0.0.0-1', {})
.reply(200, '', { 'x-powered-by': 'Nodejitsu' });
})
+}).addBatch({
+ // This tests jitsu's ability to infer the app name.
+ 'snapshots list': shouldNodejitsuOk(function setup() {
+
+ // Rest the package.json of our fixture app
+ var packageFile = path.join(__dirname, '..', 'fixtures', 'example-app', 'package.json');
+ var pkg = {
+ name: 'example-app',
+ subdomain: 'example-app',
+ scripts: { start: 'server.js' },
+ version: '0.0.0'
+ };
+
+ fs.writeFileSync(packageFile, JSON.stringify(pkg))
+
+ // Change directories
+ process.chdir(path.join(__dirname, '..', 'fixtures', 'example-app'));
+
+
+ nock('http://api.mockjitsu.com')
+ .get('/apps/tester/example-app/snapshots')
+ .reply(200, {
+ snapshots: [{
+ id: '0.0.0',
+ ctime: new Date(),
+ md5: 'q34rq43r5t5g4w56t45t'
+ }]
+ }, { 'x-powered-by': 'Nodejitsu' });
+ })
}).export(module);

0 comments on commit 398a5ce

Please sign in to comment.