added connection/disconnection tests

This commit is contained in:
brianc 2010-10-03 00:45:10 -05:00
parent 80ed3e7ffe
commit 730321dbd4
2 changed files with 15 additions and 6 deletions

View File

@ -3,7 +3,7 @@ var sys = require('sys');
var net = require('net');
var NUL = '\0';
var chars = ['R','S','K','Z','Q','C','T','D'];
var chars = ['R','S','K','Z','Q','C','T','D','X'];
var charBuff = Buffer(chars.join(''),'utf8');
var UTF8 = {};
for(var i = 0; i < charBuff.length; i++){
@ -51,6 +51,11 @@ Client.prototype.connect = function() {
this.con = con;
};
Client.prototype.disconnect = function() {
var terminationBuffer = new Buffer([UTF8.X,0,0,0,4]);
this.con.write(terminationBuffer);
};
var Parser = function(buffer) {
this.offset = 0;
this.buffer = buffer;

View File

@ -8,9 +8,13 @@ var client = new Client({
database: 'pgjstest'
});
client.connect();
client.query('create temporary table bang (id integer)');
client.query('insert into bang(id) VALUES(1)');
client.query('select * from bang',function(err, results, fields) {
assert.equal(err, null);
client.on('ReadyForQuery', function() {
assert.ok(true, 'Connected');
client.disconnect();
});
// client.query('create temporary table bang (id integer)');
// client.query('insert into bang(id) VALUES(1)');
// client.query('select * from bang',function(err, results, fields) {
// assert.equal(err, null);
// });