add failing test for #130

This commit is contained in:
brianc 2012-05-30 22:40:49 -05:00
parent dd84db367b
commit 66ea0249d8
4 changed files with 29 additions and 8 deletions

View File

@ -1,10 +1,3 @@
var helper = require(__dirname+'/../test-helper');
//creates a client from cli parameters
helper.client = function() {
var client = new Client(helper.config);
client.connect();
return client;
};
module.exports = helper;

View File

@ -0,0 +1,17 @@
var helper = require(__dirname + '/../test-helper');
var exec = require('child_process').exec;
helper.pg.defaults.poolIdleTimeout = 1000;
helper.pg.connect(helper.config, function(err,client) {
client.query("SELECT pg_backend_pid()", function(err, result) {
var pid = result.rows[0].pg_backend_pid;
exec('psql -c "select pg_terminate_backend('+pid+')" template1', assert.calls(function (error, stdout, stderr) {
assert.isNull(error);
}));
});
});
helper.pg.on('error', function(err, client) {
//swallow errors
});

View File

@ -1,10 +1,18 @@
var helper = require(__dirname + '/../test-helper');
//TODO would this be better served set at ../test-helper?
if(helper.args.native) {
Client = require(__dirname + '/../../lib/native');
helper.Client = Client;
helper.pg = helper.pg.native;
}
//creates a client from cli parameters
helper.client = function() {
var client = new Client(helper.config);
client.connect();
return client;
};
//export parent helper stuffs
module.exports = helper;

View File

@ -6,6 +6,7 @@ MemoryStream = function() {
this.packets = [];
};
helper.sys.inherits(MemoryStream, EventEmitter);
var p = MemoryStream.prototype;
@ -14,6 +15,8 @@ p.write = function(packet) {
this.packets.push(packet);
};
p.writable = true;
createClient = function() {
var stream = new MemoryStream();
stream.readyState = "open";