mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-18 15:55:05 +00:00
added connection/disconnection tests
This commit is contained in:
parent
80ed3e7ffe
commit
730321dbd4
@ -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;
|
||||
|
||||
@ -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);
|
||||
// });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user