node-postgres/test/unit/test-helper.js

26 lines
583 B
JavaScript
Raw Normal View History

2011-02-24 09:50:43 +08:00
var helper = require(__dirname+'/../test-helper');
var EventEmitter = require('events').EventEmitter;
var Connection = require('connection');
2010-10-07 08:59:20 +08:00
MemoryStream = function() {
EventEmitter.call(this);
2010-10-07 10:34:51 +08:00
this.packets = [];
2010-10-07 08:59:20 +08:00
};
2011-02-24 09:50:43 +08:00
helper.sys.inherits(MemoryStream, EventEmitter);
2010-10-07 08:59:20 +08:00
var p = MemoryStream.prototype;
2010-10-08 09:00:49 +08:00
p.write = function(packet) {
this.packets.push(packet);
};
createClient = function() {
var stream = new MemoryStream();
stream.readyState = "open";
var client = new Client({
2010-10-25 11:52:12 +08:00
connection: new Connection({stream: stream})
});
client.connect();
2010-10-20 12:02:33 +08:00
return client;
};