Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit fed35e4

Browse files
committed
feat(maxUses): added maxUses test
1 parent ffda23b commit fed35e4

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

test/maxuses.test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import test from 'blue-tape'
2+
import createPool from '../src'
3+
4+
let phantomPool
5+
test('create pool with maxUses', async () => {
6+
phantomPool = createPool({
7+
maxUses: 3,
8+
min: 1,
9+
max: 1,
10+
})
11+
})
12+
13+
test('instance is removed after 3 acquires', async (t) => {
14+
const acquire1 = await phantomPool.acquire()
15+
await phantomPool.release(acquire1)
16+
const acquire2 = await phantomPool.acquire()
17+
t.equal(acquire1, acquire2)
18+
await phantomPool.release(acquire2)
19+
const acquire3 = await phantomPool.acquire()
20+
t.equal(acquire1, acquire3)
21+
await phantomPool.release(acquire3)
22+
const acquire4 = await phantomPool.acquire()
23+
t.notEqual(acquire1, acquire4)
24+
await phantomPool.release(acquire4)
25+
})
26+
27+
test('destroy pool', async () => {
28+
await phantomPool.drain()
29+
return phantomPool.clear()
30+
})

0 commit comments

Comments
 (0)