Skip to content

Commit

Permalink
feat(maxUses): added maxUses test
Browse files Browse the repository at this point in the history
  • Loading branch information
olalonde committed Feb 7, 2017
1 parent ffda23b commit fed35e4
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/maxuses.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import test from 'blue-tape'
import createPool from '../src'

let phantomPool
test('create pool with maxUses', async () => {
phantomPool = createPool({
maxUses: 3,
min: 1,
max: 1,
})
})

test('instance is removed after 3 acquires', async (t) => {
const acquire1 = await phantomPool.acquire()
await phantomPool.release(acquire1)
const acquire2 = await phantomPool.acquire()
t.equal(acquire1, acquire2)
await phantomPool.release(acquire2)
const acquire3 = await phantomPool.acquire()
t.equal(acquire1, acquire3)
await phantomPool.release(acquire3)
const acquire4 = await phantomPool.acquire()
t.notEqual(acquire1, acquire4)
await phantomPool.release(acquire4)
})

test('destroy pool', async () => {
await phantomPool.drain()
return phantomPool.clear()
})

1 comment on commit fed35e4

@mikedaly
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Thanks for the test!

Please sign in to comment.