node-postgres/test/unit/test-helper.js
2011-08-29 02:35:08 -05:00

28 lines
632 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);
};
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;