Skip to content
Browse files

Add assertion to generic pool test, adjust name of optional callback

  • Loading branch information...
1 parent 6fdd2a6 commit d3d8fd8ef218c623b140469153e2ac0e5c3a7592 @cosbynator cosbynator committed
Showing with 7 additions and 5 deletions.
  1. +4 −4 lib/generic-pool.js
  2. +3 −1 test/generic-pool.test.js
View
8 lib/generic-pool.js
@@ -364,19 +364,19 @@ exports.Pool = function (factory) {
return function() {
var callerArgs = arguments;
var callerCallback = callerArgs[callerArgs.length - 1];
- var hasCallback = typeof callerCallback === 'function';
+ var callerHasCallback = typeof callerCallback === 'function';
me.acquire(function(err, client) {
if(err) {
- if(hasCallback) {
+ if(callerHasCallback) {
callerCallback(err);
}
return;
}
- var args = [client].concat(Array.prototype.slice.call(callerArgs, 0, hasCallback ? -1 : undefined));
+ var args = [client].concat(Array.prototype.slice.call(callerArgs, 0, callerHasCallback ? -1 : undefined));
args.push(function() {
me.release(client);
- if(hasCallback) {
+ if(callerHasCallback) {
callerCallback.apply(null, arguments);
}
});
View
4 test/generic-pool.test.js
@@ -267,14 +267,16 @@ module.exports = {
idleTimeoutMillis : 100
});
- var pooledFn = pool.pooled(function(client, arg) {
+ var pooledFn = pool.pooled(function(client, arg, cb) {
assert.equal(arg, "Arg!");
assertion_count += 1;
+ cb();
});
pooledFn("Arg!");
beforeExit(function() {
+ assert.equal(pool.getPoolSize(), 0);
assert.equal(assertion_count, 1);
});

0 comments on commit d3d8fd8

Please sign in to comment.
Something went wrong with that request. Please try again.