683d636501
1. Pass an error to an active query if the client is ended while a query is in progress. 2. actually emit 'end' event on the client when the stream ends 3. do not emit an error from native bindings if lasterror is null
25 lines
853 B
JavaScript
25 lines
853 B
JavaScript
var helper = require(__dirname + '/test-helper');
|
|
var util = require('util');
|
|
|
|
test('error during query execution', function() {
|
|
var client = new Client();
|
|
client.connect(assert.success(function() {
|
|
var sleepQuery = 'select pg_sleep(5)';
|
|
client.query(sleepQuery, assert.calls(function(err, result) {
|
|
assert(err);
|
|
client.end();
|
|
assert.emits(client, 'end');
|
|
}));
|
|
var client2 = new Client();
|
|
client2.connect(assert.success(function() {
|
|
var killIdleQuery = "SELECT procpid, (SELECT pg_terminate_backend(procpid)) AS killed FROM pg_stat_activity WHERE current_query = $1";
|
|
client2.query(killIdleQuery, [sleepQuery], assert.calls(function(err, res) {
|
|
assert.ifError(err);
|
|
assert.equal(res.rowCount, 1);
|
|
client2.end();
|
|
assert.emits(client2, 'end');
|
|
}));
|
|
}));
|
|
}));
|
|
});
|