Skip to content

Commit 3f6fc19

Browse files
committed
add test for pool+domains
1 parent abed142 commit 3f6fc19

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

test/integration/connection/test-domains.js

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ var d2 = domain.create();
55
var d3 = domain.create();
66
var d4 = domain.create();
77
var d5 = domain.create();
8-
var err1, err2, err3, err4, err5;
8+
var d6 = domain.create();
9+
var err1, err2, err3, err4, err5, err6;
910

1011
d1.run(function() {
1112
var common = require('../../common');
1213
var connection = common.createConnection();
14+
var pool = common.createPool();
1315
var assert = require('assert');
1416

1517
d2.run(function() {
@@ -20,26 +22,34 @@ d1.run(function() {
2022
});
2123

2224
d3.run(function() {
23-
connection.query('SELECT 2', function(err, _rows, _fields) {
25+
pool.query('SELECT 2', function(err, _rows, _fields) {
2426
if (err) throw err;
2527
throw new Error('inside domain 3');
2628
});
2729
});
2830

2931
d4.run(function() {
30-
connection.ping(function() {
31-
throw new Error('inside domain 4');
32-
});
32+
connection.ping(function() {
33+
throw new Error('inside domain 4');
34+
});
3335
});
3436

3537
d5.run(function() {
36-
connection.statistics(function(err, stat) {
37-
throw new Error('inside domain 5');
38-
});
38+
connection.statistics(function(err, stat) {
39+
throw new Error('inside domain 5');
40+
});
41+
});
42+
43+
d6.run(function() {
44+
pool.getConnection(function(err, conn) {
45+
conn.release();
46+
throw new Error('inside domain 6');
47+
});
3948
});
4049

4150
connection.end();
4251
setTimeout(function() {
52+
pool.end();
4353
throw new Error('inside domain 1');
4454
}, 100);
4555

@@ -55,6 +65,9 @@ d1.run(function() {
5565
d5.on('error', function(err) {
5666
err5 = err;
5767
});
68+
d6.on('error', function(err) {
69+
err6 = err;
70+
});
5871
});
5972

6073
d1.on('error', function(err) {
@@ -67,4 +80,5 @@ process.on('exit', function() {
6780
assert.equal(''+err3, 'Error: inside domain 3')
6881
assert.equal(''+err4, 'Error: inside domain 4')
6982
assert.equal(''+err5, 'Error: inside domain 5')
83+
assert.equal(''+err6, 'Error: inside domain 6')
7084
});

0 commit comments

Comments
 (0)