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

31 lines
653 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;
2011-08-29 15:35:08 +08:00
var Connection = require(__dirname + '/../../lib/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
};
2012-05-31 11:40:49 +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);
};
2012-05-31 11:40:49 +08:00
p.writable = true;
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;
};
module.exports = helper;