Skip to content
Permalink
Browse files

[fix test] Ensure that callback is invoked in fix from #236. Update t…

…ests accordingly
  • Loading branch information...
indexzero committed Jul 10, 2012
1 parent bfb0a05 commit 746d0b3366a911663a134e698f3bd87c544672a8
Showing with 10 additions and 97 deletions.
  1. +5 −2 lib/jitsu/package.js
  2. +5 −95 test/commands/apps-test.js
@@ -59,8 +59,11 @@ package.get = function (dir, options, callback) {
if (err) {
if (err.toString() === "Error: Invalid package.json file") {
jitsu.log.error(err.toString())
jitsu.log.error('Please make sure ' + (path.join(dir, '/package.json')).grey + ' is valid JSON');
return false;
return callback(
'Please make sure ' + (path.join(dir, '/package.json')).grey + ' is valid JSON',
false,
false
);
}
return package.create(dir, callback);
}
@@ -354,104 +354,14 @@ vows.describe('jitsu/commands/apps').addBatch({
assert.ok(!err);
})
}).addBatch({
'apps deploy': shouldNodejitsuOk('should be able to handle a broken package.json', function setup() {

'apps deploy': shouldNodejitsuOk('should display an error on broken package.json', function setup() {
//
// Simulate a broken package.json
//
useAppFixture('{ "name": "example-app", "subdomain": "example-app", }');

jitsu.prompt.override.answer = 'yes';
jitsu.prompt.override.name = 'example-app';
jitsu.prompt.override.subdomain = 'example-app';
jitsu.prompt.override.version = '0.0.0-1';
jitsu.prompt.override['scripts.start'] = 'server.js';
jitsu.prompt.override['engines.node'] = '0.6.x';

nock('http://api.mockjitsu.com')
.filteringRequestBody(function (route) {
return '*';
})
.post('/apps/tester/example-app/snapshots/0.0.0-2', '*')
.reply(200, {
app: { state: 'stopped' }
}, { 'x-powered-by': 'Nodejitsu' })

nock('http://api.mockjitsu.com')
.post('/apps/tester/example-app/available', {
name: 'example-app',
subdomain: 'example-app',
scripts: {
start: 'server.js'
},
version: '0.0.0-1',
engines: {
node: '0.6.x'
}
})
.reply(200, {
available: true,
}, { 'x-powered-by': 'Nodejitsu' })
.get('/apps/tester/example-app')
.reply(200, {
app: {
name: 'example-app',
state: 'stopped',
subdomain:'example-app',
scripts: { start: './server.js' },
snapshots: [{ filename: 'FILENAME' }]
}
}, { 'x-powered-by': 'Nodejitsu' })
.put('/apps/tester/example-app', {
name: 'example-app',
subdomain: 'example-app',
scripts: {
start: 'server.js'
},
version: '0.0.0-2',
engines: { node: '0.6.x' }
})
.reply(200, {
app: { state: 'stopped' }
}, { 'x-powered-by': 'Nodejitsu' })
.post('/apps/tester/example-app/snapshots/0.0.0-2/activate', {})
.reply(200, {
app: {
name: 'example-app',
subdomain: 'example-app',
scripts: { start: 'server.js' },
version: '0.0.0-2'
}
}, { 'x-powered-by': 'Nodejitsu' })
.post('/apps/tester/example-app/stop', {})
.reply(200, {
app: {
name: 'example-app',
subdomain: 'example-app',
scripts: { start: 'server.js' },
version: '0.0.0-2'
}
}, { 'x-powered-by': 'Nodejitsu' })
.post('/apps/tester/example-app/start', {})
.reply(200, {
app: {
name: 'example-app',
subdomain: 'example-app',
scripts: { start: 'server.js' },
version: '0.0.0-2'
}
}, { 'x-powered-by': 'Nodejitsu' })
.get('/apps/tester/example-app')
.reply(200, {
app: {
name: 'example-app',
subdomain: 'example-app',
scripts: { start: 'server.js' },
version: '0.0.0-1'
}
}, { 'x-powered-by': 'Nodejitsu' });

}, function assertion (err) {
}, function assertion (err, _) {
process.chdir(mainDirectory);
assert.ok(!err);
assert.ok(!!err);
})
}).addBatch({
'apps deploy': shouldNodejitsuOk('should prompt for credentials', function setup() {

0 comments on commit 746d0b3

Please sign in to comment.
You can’t perform that action at this time.