Skip to content

Commit 0188277

Browse files
asadbek2021hjr3
authored andcommitted
fix: test resolve should be called when the last client is removed
1 parent 8e48dda commit 0188277

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/pg-pool/test/idle-timeout.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ describe('idle timeout', () => {
2525
it(
2626
'times out and removes clients when others are also removed',
2727
co.wrap(function* () {
28+
let currentClient = 1
2829
const pool = new Pool({ idleTimeoutMillis: 10 })
2930
const clientA = yield pool.connect()
3031
const clientB = yield pool.connect()
@@ -35,7 +36,12 @@ describe('idle timeout', () => {
3536
pool.on('remove', () => {
3637
expect(pool.idleCount).to.equal(0)
3738
expect(pool.totalCount).to.equal(0)
38-
resolve()
39+
40+
if (currentClient >= 2) {
41+
resolve()
42+
} else {
43+
currentClient++
44+
}
3945
})
4046
})
4147

0 commit comments

Comments
 (0)