From 891aacce54159752b1aa7fa210ff75caba737211 Mon Sep 17 00:00:00 2001 From: brianc Date: Sun, 3 Oct 2010 01:08:04 -0500 Subject: [PATCH] connection tests w/ two clients --- lib/index.js | 4 ++++ test/api-tests.js | 25 +++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/lib/index.js b/lib/index.js index 23afd65d..36613829 100644 --- a/lib/index.js +++ b/lib/index.js @@ -56,6 +56,10 @@ Client.prototype.disconnect = function() { this.con.write(terminationBuffer); }; +Client.prototype.query = function() { + +}; + var Parser = function(buffer) { this.offset = 0; this.buffer = buffer; diff --git a/test/api-tests.js b/test/api-tests.js index a15ecc81..665812af 100644 --- a/test/api-tests.js +++ b/test/api-tests.js @@ -1,13 +1,26 @@ require(__dirname+"/test-helper"); -var client = new Client({ - user: 'brian', - database: 'pgjstest' +//little helper to make a +//fresh client to the test DB +var makeClient = function() { + return new Client({ + user: 'brian', + database: 'pgjstest' + }); +}; + +var client1 = makeClient(); +client1.connect(); +client1.on('ReadyForQuery', function() { + console.log('client1 ready for query'); + client1.disconnect(); }); -client.connect(); -client.on('ReadyForQuery', function() { - client.disconnect(); +var client2 = makeClient(); +client2.connect(); +client2.on('ReadyForQuery', function() { + console.log('client2 ready for query'); + client2.disconnect(); }); // client.query('create temporary table bang (id integer)');