forked from brianc/node-postgres
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnection-tests.js
36 lines (31 loc) · 969 Bytes
/
connection-tests.js
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
31
32
33
34
35
36
var helper = require(__dirname + "/../test-helper");
var Client = require(__dirname + "/../../lib/native");
var domain = require('domain');
test('connecting with wrong parameters', function() {
var con = new Client("user=asldfkj hostaddr=127.0.0.1 port=5432 dbname=asldkfj");
assert.emits(con, 'error', function(error) {
assert.ok(error != null, "error should not be null");
con.end();
});
con.connect();
});
test('connects', function() {
var con = new Client(helper.config);
con.connect();
assert.emits(con, 'connect', function() {
test('disconnects', function() {
con.end();
})
})
})
test('preserves domain', function() {
var dom = domain.create();
dom.run(function() {
var con = new Client(helper.config);
assert.ok(dom === require('domain').active, 'domain is active');
con.connect(function() {
assert.ok(dom === require('domain').active, 'domain is still active');
con.end();
});
});
})