Skip to content

Commit

Permalink
[fix test] Ensure that callback is invoked in fix from #236. Update t…
Browse files Browse the repository at this point in the history
…ests accordingly
  • Loading branch information
indexzero committed Jul 10, 2012
1 parent bfb0a05 commit 746d0b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 97 deletions.
7 changes: 5 additions & 2 deletions lib/jitsu/package.js
Expand Up @@ -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);
}
Expand Down
100 changes: 5 additions & 95 deletions test/commands/apps-test.js
Expand Up @@ -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() {
Expand Down

0 comments on commit 746d0b3

Please sign in to comment.