Skip to content

Commit

Permalink
fixed single droplet IP returning
Browse files Browse the repository at this point in the history
  • Loading branch information
hortinstein committed May 29, 2013
1 parent 9640935 commit 5e45f9f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# brinydeep
=========
## 0.56 notes
* now correctly returns IPs if called on a single ID
## 0.55 notes
* fixed error checking, digital ocean made a minor change in their JSON
## 0.51 notes
Expand Down
10 changes: 8 additions & 2 deletions lib/ip_provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ function validate_ips(droplet_ids, requestor, droplet_list, callback) {
return;
}
};
callback(null,ip_list)
if (ip_list.length === 1) { //just returns one element for ip_list
ip_list = ip_list[0];
}
callback(null, ip_list)
}

function get_ips(droplet_ids, requestor, callback) {
Expand All @@ -25,7 +28,10 @@ function get_ips(droplet_ids, requestor, callback) {
if (e) {
callback(e, o);
} else {
validate_ips(droplet_ids,requestor, o, callback);
if (!(Array.isArray(o))) { //looks cleaner with this slight hack
o = [o];
};
validate_ips(droplet_ids, requestor, o, callback);
}
});
};
Expand Down
12 changes: 11 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,16 @@ describe('bulk droplet info', function() {
//console.log(test_droplet_ids);
done();
});
it('should be able to provide all droplet IPs', function(done) {
it('should be able to provide one droplet IPs', function(done) {
this.timeout(50 * 1000); //unclear how long this should take this will disable the timeout
brinydeep.get_ips(test_droplet_ids[0],function (e,o) {
console.log(o);
o.ip_address.should.not.equal(null);
done();
});
});

it('should be able to provide all droplet IP', function(done) {
this.timeout(50 * 1000); //unclear how long this should take this will disable the timeout
brinydeep.get_ips(test_droplet_ids,function (e,o) {
o.length.should.equal(3);
Expand Down Expand Up @@ -132,6 +141,7 @@ describe('droplet functions', function() {

it('should be able to destroy test droplets', function(done) {
brinydeep.destroy(test_droplet_ids, function(e, o) {
console.log(e,o);
o[0].status.should.equal('OK');
o[1].status.should.equal('OK');
o[2].status.should.equal('OK');
Expand Down

0 comments on commit 5e45f9f

Please sign in to comment.