Skip to content

Commit 0c190f9

Browse files
committed
Test code improvements for pool tests
1 parent cdbd4c8 commit 0c190f9

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

test/pool.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,18 @@ describe('2. pool.js', function() {
115115
}); // 2.2
116116

117117
describe('2.3 poolMax', function() {
118+
let pool;
119+
let isPoolClosed = true;
120+
121+
afterEach(async function() {
122+
// Ensure that pool is closed irrespective of any test failures.
123+
// Not closing a pool impacts the poolCache, which may be used by later
124+
// tests and lead to false test failures.
125+
if (!isPoolClosed && pool) {
126+
await pool.close(0);
127+
isPoolClosed = true;
128+
}
129+
});
118130

119131
it('2.3.1 poolMax cannot be a negative value', async function() {
120132
const config = {...dbConfig,
@@ -167,7 +179,8 @@ describe('2. pool.js', function() {
167179
poolTimeout: 1,
168180
queueTimeout: 1
169181
};
170-
const pool = await oracledb.createPool(config);
182+
pool = await oracledb.createPool(config);
183+
isPoolClosed = false;
171184
conns.push(await pool.getConnection());
172185
conns.push(await pool.getConnection());
173186
await assert.rejects(
@@ -187,6 +200,7 @@ describe('2. pool.js', function() {
187200
}, 2000);
188201
});
189202
await pool.close(0);
203+
isPoolClosed = true;
190204
});
191205

192206
}); // 2.3

0 commit comments

Comments
 (0)