node-postgres/test/unit/test-helper.js
Konstantin Petryaev ad65c7b1bc Fix of pool leaking by TCP-keepalive (#918)
* fix of bug with pool leaking by TCP keep-alives

* add test for check setKeepAlive on connect

* fix mistake with var

* fix mistake with var
2016-06-21 14:49:41 -05:00

33 lines
685 B
JavaScript

var helper = require(__dirname+'/../test-helper');
var EventEmitter = require('events').EventEmitter;
var Connection = require(__dirname + '/../../lib/connection');
MemoryStream = function() {
EventEmitter.call(this);
this.packets = [];
};
helper.sys.inherits(MemoryStream, EventEmitter);
var p = MemoryStream.prototype;
p.write = function(packet) {
this.packets.push(packet);
};
p.setKeepAlive = function(){};
p.writable = true;
createClient = function() {
var stream = new MemoryStream();
stream.readyState = "open";
var client = new Client({
connection: new Connection({stream: stream})
});
client.connect();
return client;
};
module.exports = helper;