From d38a7f5ed7d5d129a5e3db65209863be683534c2 Mon Sep 17 00:00:00 2001 From: brianc Date: Fri, 29 Oct 2010 00:46:08 -0500 Subject: [PATCH] added tests to support noData & extra query scenarios but currently failing...ignoring for now --- lib/connection.js | 2 +- test/integration/client/no-datat-tests.js | 40 +++++++++++++++++++ .../client/prepared-statement-tests.js | 1 + 3 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 test/integration/client/no-datat-tests.js diff --git a/lib/connection.js b/lib/connection.js index c89523e7..a309ee6b 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -85,7 +85,7 @@ p.writeInt32 = function(buffer, offset, value) { p.end = function() { var terminationBuffer = new Buffer([0x58,0,0,0,4]); - var wrote = this.stream.end(terminationBuffer); + var wrote = this.stream.write(terminationBuffer); }; p.query = function(text) { diff --git a/test/integration/client/no-datat-tests.js b/test/integration/client/no-datat-tests.js new file mode 100644 index 00000000..b5f7a8f4 --- /dev/null +++ b/test/integration/client/no-datat-tests.js @@ -0,0 +1,40 @@ +var helper = require(__dirname + '/test-helper'); + +test("noData message handling", function() { + return false; + var client = helper.client(); + + client.query({ + name: 'boom', + text: 'create temp table boom(id serial, size integer)' + }); + + client.query({ + name: 'insert', + text: 'insert into boom(size) values($1)', + values: [100] + }); + + client.query({ + name: 'insert', + values: [101] + }); + + client.connection.on('message', console.log); + + var x = client.query({ + name: 'fetch', + text: 'select size from boom' + }); + + assert.raises(x, 'row', function(row) { + assert.equal(row.fields[0], 100); + + assert.raises(x, 'row', function(row) { + assert.equal(row.fields[0], 101); + }); + }); + + x.on('end', query.end()); + +}); diff --git a/test/integration/client/prepared-statement-tests.js b/test/integration/client/prepared-statement-tests.js index ccdc308e..d8267b70 100644 --- a/test/integration/client/prepared-statement-tests.js +++ b/test/integration/client/prepared-statement-tests.js @@ -151,3 +151,4 @@ test("prepared statements on different clients", function() { }); }); +