forked from brianc/node-postgres
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherror-tests.js
More file actions
30 lines (28 loc) · 1006 Bytes
/
Copy patherror-tests.js
File metadata and controls
30 lines (28 loc) · 1006 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var helper = require(__dirname + '/test-helper');
var Connection = require(__dirname + '/../../../lib/connection');
test("connection emits stream errors", function() {
var con = new Connection({stream: new MemoryStream()});
assert.emits(con, 'error', function(err) {
assert.equal(err.message, "OMG!");
});
con.connect();
con.stream.emit('error', new Error("OMG!"));
});
test('connection emits ECONNRESET errors during normal operation', function() {
var con = new Connection({stream: new MemoryStream()});
con.connect();
assert.emits(con, 'error', function(err) {
assert.equal(err.code, 'ECONNRESET');
});
var e = new Error('Connection Reset');
e.code = 'ECONNRESET';
con.stream.emit('error', e);
});
test('connection does not emit ECONNRESET errors during disconnect', function() {
var con = new Connection({stream: new MemoryStream()});
con.connect();
var e = new Error('Connection Reset');
e.code = 'ECONNRESET';
con.end();
con.stream.emit('error', e);
});