Skip to content

Commit 15df1fa

Browse files
committed
Make pool cache tests work in promise-less Node 0.10
1 parent 7142af3 commit 15df1fa

File tree

2 files changed

+40
-80
lines changed

2 files changed

+40
-80
lines changed

test/list.txt

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -811,14 +811,12 @@ Overview of node-oracledb functional tests
811811
67.1.10 throws an error if the pool specified in getPool doesn't exist
812812
67.1.11 does not throw an error if multiple pools are created without a poolAlias in the same call stack
813813
67.2 oracledb.getConnection functional tests
814-
67.2.1 gets a connection from the default pool, returns a promise
815-
67.2.2 gets a connection from the default pool, invokes the callback
816-
67.2.3 gets a connection from the pool with the specified alias, returns a promise
817-
67.2.4 gets a connection from the pool with the specified alias, invokes the callback
818-
67.2.5 throws an error if an attempt is made to use the default pool when it does not exist
819-
67.2.6 throws an error if an attempt is made to use a poolAlias for a pool that is not in the cache
820-
67.2.7 gets a connection from the default pool, even after an aliased pool is created
821-
67.2.8 uses the right pool, even after multiple pools are created
814+
67.2.1 gets a connection from the default pool
815+
67.2.2 gets a connection from the pool with the specified alias when no alias is specified
816+
67.2.3 throws an error if an attempt is made to use the default pool when it does not exist
817+
67.2.4 throws an error if an attempt is made to use a poolAlias for a pool that is not in the cache
818+
67.2.5 gets a connection from the default pool, even after an aliased pool is created
819+
67.2.6 uses the right pool, even after multiple pools are created
822820

823821
68. multipleLobInsertion.js
824822
68.1 inserts multiple BLOBs

test/poolCache.js

Lines changed: 34 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -301,63 +301,49 @@ describe('67. poolCache.js', function() {
301301
});
302302

303303
it('67.1.11 does not throw an error if multiple pools are created without a poolAlias in the same call stack', function(done) {
304-
var pool1Promise;
305-
var pool2Promise;
304+
var pool1;
305+
var pool2;
306306

307-
pool1Promise = oracledb.createPool(dbConfig);
308-
309-
pool2Promise = oracledb.createPool(dbConfig);
307+
async.parallel(
308+
[
309+
function(callback) {
310+
oracledb.createPool(dbConfig, function(err, pool) {
311+
should.not.exist(err);
310312

311-
Promise.all([pool1Promise, pool2Promise])
312-
.then(function(pools) {
313-
pools[0].close(function(err){
314-
should.not.exist(err);
313+
pool1 = pool;
315314

316-
pools[1].close(function(err){
315+
callback();
316+
});
317+
},
318+
function(callback) {
319+
oracledb.createPool(dbConfig, function(err, pool) {
317320
should.not.exist(err);
318321

319-
done();
322+
pool2 = pool;
323+
324+
callback();
320325
});
321-
});
322-
})
323-
.catch(function(createPoolErr) {
324-
// Second pool should have failed, get the default and close it. Need
325-
// to wait briefly as Promise.all catches after first promise rejection
326-
// so default pool may not have been created yet.
327-
setTimeout(function() {
328-
oracledb.getPool().close(function(err) {
326+
}
327+
],
328+
function(createPoolErr) {
329+
should.not.exist(createPoolErr);
330+
331+
pool1.close(function(err) {
332+
should.not.exist(err);
333+
334+
pool2.close(function(err) {
329335
should.not.exist(err);
330336

331337
done(createPoolErr);
332338
});
333-
}, 100);
334-
});
339+
});
340+
}
341+
);
335342
});
336343
});
337344

338345
describe('67.2 oracledb.getConnection functional tests', function() {
339-
it('67.2.1 gets a connection from the default pool, returns a promise', function(done) {
340-
oracledb.createPool(dbConfig, function(err, pool) {
341-
should.not.exist(err);
342-
343-
// Not specifying a poolAlias, default will be used
344-
oracledb.getConnection()
345-
.then(function(conn) {
346-
return conn.close();
347-
})
348-
.then(function() {
349-
return pool.close();
350-
})
351-
.then(function() {
352-
done();
353-
})
354-
.catch(function(err) {
355-
done(err);
356-
});
357-
});
358-
});
359-
360-
it('67.2.2 gets a connection from the default pool, invokes the callback', function(done) {
346+
it('67.2.1 gets a connection from the default pool when no alias is specified', function(done) {
361347
oracledb.createPool(dbConfig, function(err, pool) {
362348
should.not.exist(err);
363349

@@ -378,31 +364,7 @@ describe('67. poolCache.js', function() {
378364
});
379365
});
380366

381-
it('67.2.3 gets a connection from the pool with the specified poolAlias, returns a promise', function(done) {
382-
var poolAlias = 'random-pool-alias';
383-
384-
dbConfig.poolAlias = poolAlias;
385-
386-
oracledb.createPool(dbConfig, function(err, pool) {
387-
should.not.exist(err);
388-
389-
oracledb.getConnection(poolAlias)
390-
.then(function(conn) {
391-
return conn.close();
392-
})
393-
.then(function() {
394-
return pool.close();
395-
})
396-
.then(function() {
397-
done();
398-
})
399-
.catch(function(err) {
400-
done(err);
401-
});
402-
});
403-
});
404-
405-
it('67.2.4 gets a connection from the pool with the specified poolAlias, invokes the callback', function(done) {
367+
it('67.2.2 gets a connection from the pool with the specified poolAlias', function(done) {
406368
var poolAlias = 'random-pool-alias';
407369

408370
dbConfig.poolAlias = poolAlias;
@@ -426,7 +388,7 @@ describe('67. poolCache.js', function() {
426388
});
427389
});
428390

429-
it('67.2.5 throws an error if an attempt is made to use the default pool when it does not exist', function(done) {
391+
it('67.2.3 throws an error if an attempt is made to use the default pool when it does not exist', function(done) {
430392
dbConfig.poolAlias = 'random-pool-alias';
431393

432394
oracledb.createPool(dbConfig, function(err, pool) {
@@ -447,7 +409,7 @@ describe('67. poolCache.js', function() {
447409
});
448410
});
449411

450-
it('67.2.6 throws an error if an attempt is made to use a poolAlias for a pool that is not in the cache', function(done) {
412+
it('67.2.4 throws an error if an attempt is made to use a poolAlias for a pool that is not in the cache', function(done) {
451413
dbConfig.poolAlias = 'random-pool-alias';
452414

453415
oracledb.createPool(dbConfig, function(err, pool) {
@@ -467,7 +429,7 @@ describe('67. poolCache.js', function() {
467429
});
468430
});
469431

470-
it('67.2.7 gets a connection from the default pool, even after an aliased pool is created', function(done) {
432+
it('67.2.5 gets a connection from the default pool, even after an aliased pool is created', function(done) {
471433
oracledb.createPool(dbConfig, function(err, pool1) {
472434
should.not.exist(err);
473435

@@ -506,7 +468,7 @@ describe('67. poolCache.js', function() {
506468
});
507469
});
508470

509-
it('67.2.8 uses the right pool, even after multiple pools are created', function(done) {
471+
it('67.2.6 uses the right pool, even after multiple pools are created', function(done) {
510472
var aliasToUse = 'random-pool-alias-2';
511473

512474
dbConfig.poolAlias = 'random-pool-alias';

0 commit comments

Comments
 (0)