Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding tests for pool relating to #90
- Loading branch information
Showing
3 changed files
with
71 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
var _ = require('underscore'); | ||
var when = require('when'); | ||
var Pool = require('../../../clients/pool').Pool; | ||
var GenericPool = require('generic-pool-redux').Pool; | ||
|
||
describe('Pool', function () { | ||
|
||
var connStub = function() { | ||
return when.resolve({end: function() {}}); | ||
}; | ||
|
||
describe('constructor', function() { | ||
|
||
it('creates an instance of the pool in the `poolInstance` property', function() { | ||
|
||
var pool = new Pool({}, {getRawConnection: function() { return connStub(); }}); | ||
|
||
expect(pool.poolInstance).to.be.an.instanceOf(GenericPool); | ||
|
||
}); | ||
|
||
}); | ||
|
||
describe('destroy', function() { | ||
|
||
it('removes the poolInstance', function() { | ||
|
||
var pool = new Pool({}, {getRawConnection: function() { return connStub(); }}); | ||
|
||
pool.destroy(); | ||
|
||
expect(pool.poolInstance).to.be.undefined; | ||
|
||
}); | ||
|
||
it('calls a callback on success', function(ok) { | ||
|
||
var pool = new Pool({}, {getRawConnection: function() { return connStub(); }}); | ||
|
||
pool.destroy(function() { | ||
ok(); | ||
}); | ||
|
||
}); | ||
|
||
it('does not fail with subsequent destroy calls', function(ok) { | ||
|
||
var pool = new Pool({}, {getRawConnection: function() { return connStub(); }}); | ||
|
||
pool.destroy(); | ||
|
||
pool.destroy(function() { | ||
ok(); | ||
}); | ||
|
||
}); | ||
|
||
}); | ||
|
||
}); |