Skip to content

Commit

Permalink
[api test minor] Be more liberal handling errors on stop.
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Mar 7, 2013
1 parent b09c66c commit f5203d7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/haibu/drone/drone.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Drone.prototype.stop = function (name, cleanup, callback) {
} }


if (typeof this.apps[name] === 'undefined') { if (typeof this.apps[name] === 'undefined') {
return callback(new Error('Cannot stop application that is not running.')); return callback();
} }


var self = this, var self = this,
Expand Down
3 changes: 1 addition & 2 deletions lib/haibu/drone/service.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ exports.createRouter = function (drone) {
var res = this.res; var res = this.res;


drone.stop(this.req.body.stop.name, function (err, result) { drone.stop(this.req.body.stop.name, function (err, result) {
if (err || !result) { if (err) {
err = err || new Error('Unknown error from drone.');
haibu.emit('error:service', 'error', err); haibu.emit('error:service', 'error', err);
return haibu.sendResponse(res, 500, { error: err }); return haibu.sendResponse(res, 500, { error: err });
} }
Expand Down
9 changes: 2 additions & 7 deletions test/drone/drone-api-test.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -279,13 +279,8 @@ vows.describe('haibu/drone/api').addBatch(


request(options, this.callback); request(options, this.callback);
}, },
"should respond with 500": function (error, response, body) { "should respond with 200": function (error, response, body) {
assert.equal(response.statusCode, 500); assert.equal(response.statusCode, 200);
},
"should respond with the appropriate error": function (error, response, body) {
var result = JSON.parse(body);
assert.isObject(result.error);
assert.equal(result.error.message, 'Cannot stop application that is not running.');
} }
} }
} }
Expand Down

0 comments on commit f5203d7

Please sign in to comment.