Skip to content

Commit 86492c1

Browse files
committed
connection error test
1 parent 30fa083 commit 86492c1

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
11
var common = require('../../common');
22
var assert = require('assert');
33

4+
var callCount = 0;
5+
var exceptionCount = 0;
6+
47
process.on('uncaughtException', function (err) {
58
assert.ifError(err);
9+
exceptionCount++;
610
});
711

812
var connection1 = common.createConnection({
9-
username: 'wtf',
1013
password: 'lol'
1114
});
1215

1316
// error will NOT bubble up to process level if `on` is used
14-
connection1.on('error', function (err) {
15-
assert.ok(err);
17+
connection1.on('error', function () {
18+
callCount++;
1619
});
1720

1821
var connection2 = common.createConnection({
19-
username: 'wtf',
2022
password: 'lol'
2123
});
2224

2325
// error will bubble up to process level if `once` is used
24-
connection2.once('error', function (err) {
25-
assert.ok(err);
26+
connection2.once('error', function () {
27+
callCount++;
28+
});
29+
30+
process.on('exit', function () {
31+
assert.equal(callCount, 2);
32+
assert.equal(exceptionCount, 0);
2633
});

0 commit comments

Comments
 (0)