2011-02-24 10:02:51 +08:00
|
|
|
var helper = require(__dirname + "/../test-helper");
|
2011-08-12 09:59:56 +08:00
|
|
|
var Client = require(__dirname + "/../../lib/native");
|
2011-02-24 10:02:51 +08:00
|
|
|
|
|
|
|
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();
|
|
|
|
});
|
2011-04-15 11:38:55 +08:00
|
|
|
|
|
|
|
con.connect();
|
2011-02-24 10:02:51 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
test('connects', function() {
|
2011-02-24 10:19:27 +08:00
|
|
|
var con = new Client(helper.connectionString());
|
2011-02-24 10:02:51 +08:00
|
|
|
con.connect();
|
|
|
|
assert.emits(con, 'connect', function() {
|
|
|
|
test('disconnects', function() {
|
|
|
|
con.end();
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|