36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
var helper = require(__dirname + "/../test-helper");
|
|
var pg = require(__dirname + "/../../../lib");
|
|
pg = pg;
|
|
|
|
//first make pool hold 2 clients
|
|
pg.defaults.poolSize = 2;
|
|
|
|
var killIdleQuery = 'SELECT procpid, (SELECT pg_terminate_backend(procpid)) AS killed FROM pg_stat_activity WHERE current_query LIKE \'<IDLE>\'';
|
|
|
|
return console.log('TEMP IGNORE THIS TO GET REST OF SUITE PASSING')
|
|
//get first client
|
|
pg.connect(helper.config, assert.success(function(client, done) {
|
|
client.id = 1;
|
|
pg.connect(helper.config, assert.success(function(client2, done2) {
|
|
client2.id = 2;
|
|
done2();
|
|
//subscribe to the pg error event
|
|
assert.emits(pg, 'error', function(error, brokenClient) {
|
|
assert.ok(error);
|
|
assert.ok(brokenClient);
|
|
assert.equal(client.id, brokenClient.id);
|
|
console.log('got pg error')
|
|
console.log('calling pg.end()')
|
|
//done2();
|
|
pg.end();
|
|
});
|
|
//kill the connection from client
|
|
client2.query(killIdleQuery, assert.success(function(res) {
|
|
//check to make sure client connection actually was killed
|
|
console.log('\nkilled query');
|
|
assert.lengthIs(res.rows, 1);
|
|
done();
|
|
}));
|
|
}));
|
|
}));
|