Skip to content

Commit

Permalink
Added basic drain test
Browse files Browse the repository at this point in the history
  • Loading branch information
NatalieWolfe committed Jul 10, 2015
1 parent 818adc3 commit a4c8902
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions tests/unit/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,25 @@ describe('PromisePool', function(){
});

describe('#drain', function(){
it('should destroy all resources');
it('should destroy all resources', function(){
var created = 0;
var destroyed = 0;
var pool = new PromisePool({
max: 10,
min: 0,
create: function(){ ++created; return {}; },
destroy: function(obj){ ++destroyed; }
});

return pool.acquire(function(conn){
return Promise.resolve();
}).then(function(){
return pool.destroyAllNow();
}).then(function(){
created.should.eql(destroyed);
});
});

it('should supply all waiting clients first');
it('should wait for all resources to be returned');
});
Expand All @@ -215,8 +233,8 @@ describe('PromisePool', function(){
func.should.be.a.function;
should.not.exist(conn);

return func('foo', 'bar').then(function(res){
res.should.eql('foobar');
return func('foo', 'bar').then(function(foobar){
foobar.should.eql('foobar');
should.exist(conn);
});
});
Expand All @@ -233,7 +251,7 @@ describe('PromisePool', function(){
})
};

return obj.func('foo', 'bar').then(function(){
return obj.func().then(function(){
should.exist(conn);
});
});
Expand Down

0 comments on commit a4c8902

Please sign in to comment.