Created
June 6, 2011 04:19
-
-
Save indexzero/1009739 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/haibu/drone/drone.js b/lib/haibu/drone/drone.js | |
index ef375c7..f94d9af 100644 | |
--- a/lib/haibu/drone/drone.js | |
+++ b/lib/haibu/drone/drone.js | |
@@ -157,15 +157,37 @@ Drone.prototype.clean = function (app, callback) { | |
// Shows details for drone with `name` managed by this instance | |
// | |
Drone.prototype.show = function (name) { | |
- return this.apps[name]; | |
-}; | |
+ var self = this, | |
+ app = this.apps[name], | |
+ appData; | |
+ | |
+ appData = { | |
+ app: this.apps[name].app, | |
+ drones: [] | |
+ }; | |
+ | |
+ if (app.drones) { | |
+ Object.keys(app.drones).forEach(function (pid) { | |
+ appData.drones.push(app.drones[pid].process); | |
+ }); | |
+ } | |
+ | |
+ return appData; | |
+} | |
// | |
// ### function list () | |
// Lists details about all drones managed by this instance | |
// | |
Drone.prototype.list = function () { | |
- return this.apps; | |
+ var self = this, | |
+ allApps = {}; | |
+ | |
+ Object.keys(this.apps).forEach(function (name) { | |
+ allApps[name] = self.show(name); | |
+ }); | |
+ | |
+ return allApps; | |
}; | |
// | |
diff --git a/test/drone/drone-api-test.js b/test/drone/drone-api-test.js | |
index 2eae275..b535fa8 100644 | |
--- a/test/drone/drone-api-test.js | |
+++ b/test/drone/drone-api-test.js | |
@@ -119,6 +119,55 @@ vows.describe('haibu/drone/api').addBatch( | |
} | |
}).addBatch({ | |
"When using the drone server": { | |
+ "a request against /drones": { | |
+ "when there are running drones": { | |
+ topic: function () { | |
+ var options = { | |
+ uri: 'http://localhost:9000/drones', | |
+ method: 'GET', | |
+ headers: { | |
+ 'Content-Type': 'application/json' | |
+ } | |
+ }; | |
+ request(options, this.callback); | |
+ }, | |
+ "should respond with 200": function (error, response, body) { | |
+ assert.equal(response.statusCode, 200); | |
+ }, | |
+ "should respond with a list of drones": function (error, response, body) { | |
+ var drones = JSON.parse(body).drones; | |
+ assert.isObject(drones); | |
+ assert.length(drones['test'].drones, 1); | |
+ } | |
+ } | |
+ } | |
+ } | |
+}).addBatch({ | |
+ "When using the drone server": { | |
+ "a request against /drones/:id": { | |
+ "when there are running drones": { | |
+ topic: function () { | |
+ var options = { | |
+ uri: 'http://localhost:9000/drones/test', | |
+ method: 'GET', | |
+ headers: { | |
+ 'Content-Type': 'application/json' | |
+ } | |
+ }; | |
+ request(options, this.callback); | |
+ }, | |
+ "should respond with 200": function (error, response, body) { | |
+ assert.equal(response.statusCode, 200); | |
+ }, | |
+ "should respond with a drone": function (error, response, body) { | |
+ var drone = JSON.parse(body); | |
+ assert.isObject(drone); | |
+ } | |
+ } | |
+ } | |
+ } | |
+}).addBatch({ | |
+ "When using the drone server": { | |
"a request against /drones/:id/stop": { | |
"when there is are running drones": { | |
topic: function () { | |
@@ -227,4 +276,4 @@ vows.describe('haibu/drone/api').addBatch( | |
server.close(); | |
} | |
} | |
-}).export(module); | |
+}).export(module); | |
\ No newline at end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment