Skip to content

Commit 524381e

Browse files
committed
Fix default pool not closing error in test suite
1 parent 64acabb commit 524381e

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

test/poolDrain.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ const oracledb = require('oracledb');
3232
const should = require('should');
3333
const dbconfig = require('./dbconfig.js');
3434

35+
function sleep(ms) {
36+
return new Promise(resolve => setTimeout(resolve, ms));
37+
}
38+
3539
describe('170. poolDrain.js', () => {
3640
before(function() {
3741
if (process.versions.modules < 57) this.skip();
@@ -59,17 +63,22 @@ describe('170. poolDrain.js', () => {
5963
err.message,
6064
"NJS-064: connection pool is closing"
6165
);
66+
} finally {
67+
await sleep(6000);
6268
}
6369
}); // 170.1
6470

6571
it('170.2 close pool without force flag (will give out an error ), and prevent new connections', async () => {
72+
let pool;
6673
try {
67-
let pool = await oracledb.createPool(settings);
74+
pool = await oracledb.createPool(settings);
6875
await pool.getConnection();
6976
await pool.close();
7077
} catch(err) {
7178
should.exist(err);
7279
(err.message).should.startWith('ORA-24422:');
80+
} finally {
81+
await pool.close(0);
7382
}
7483
}); // 170.2
7584

@@ -83,6 +92,8 @@ describe('170. poolDrain.js', () => {
8392
should.strictEqual(pool.status, oracledb.POOL_STATUS_DRAINING);
8493
} catch(err) {
8594
should.not.exist(err);
95+
} finally {
96+
await sleep(3000);
8697
}
8798
}); // 170.3
8899

@@ -178,6 +189,8 @@ describe('170. poolDrain.js', () => {
178189
pool_2.close(drainTime);
179190
} catch(err) {
180191
should.not.exist(err);
192+
} finally {
193+
await sleep(3000);
181194
}
182195
}); // 170.9
183196

@@ -215,8 +228,9 @@ describe('170. poolDrain.js', () => {
215228
});
216229

217230
it('170.12 drainTime = -3', async () => {
231+
let pool;
218232
try {
219-
let pool = await oracledb.createPool(settings);
233+
pool = await oracledb.createPool(settings);
220234

221235
await pool.getConnection();
222236
await pool.getConnection();
@@ -228,12 +242,15 @@ describe('170. poolDrain.js', () => {
228242
} catch(err) {
229243
should.exist(err);
230244
should.strictEqual(err.message, "NJS-005: invalid value for parameter 1");
245+
} finally {
246+
await pool.close(0);
231247
}
232248
});
233249

234250
it('170.13 drainTime = NaN', async () => {
251+
let pool;
235252
try {
236-
let pool = await oracledb.createPool(settings);
253+
pool = await oracledb.createPool(settings);
237254

238255
await pool.getConnection();
239256
await pool.getConnection();
@@ -245,6 +262,8 @@ describe('170. poolDrain.js', () => {
245262
} catch(err) {
246263
should.exist(err);
247264
should.strictEqual(err.message, "NJS-005: invalid value for parameter 1");
265+
} finally {
266+
await pool.close(0);
248267
}
249268
});
250269

@@ -268,6 +287,8 @@ describe('170. poolDrain.js', () => {
268287
pool_2.close(1);
269288
} catch(err) {
270289
should.not.exist(err);
290+
} finally {
291+
await sleep(4000);
271292
}
272293
});
273294

@@ -297,6 +318,8 @@ describe('170. poolDrain.js', () => {
297318
pool_2.close(1);
298319
} catch(err) {
299320
should.not.exist(err);
321+
} finally {
322+
await sleep(4000);
300323
}
301324
});
302325

test/poolPing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ describe("73. poolPing.js", function() {
387387
);
388388
},
389389
function(cb) {
390-
if(userSetInterval != null) {
390+
if(userSetInterval !== null) {
391391
pool.close(function(err) {
392392
should.not.exist(err);
393393
});

0 commit comments

Comments
 (0)