From 3f5df0afa26944e026be4fbe75b59fc97e25bd99 Mon Sep 17 00:00:00 2001 From: brianc Date: Wed, 17 Apr 2013 10:29:21 -0500 Subject: [PATCH] make tests pass on pg@8.4.9 --- lib/result.js | 2 +- .../client/query-error-handling-tests.js | 2 +- .../client/result-metadata-tests.js | 40 ++++++++++--------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/lib/result.js b/lib/result.js index fd920ed..4eabbe7 100644 --- a/lib/result.js +++ b/lib/result.js @@ -8,7 +8,7 @@ var Result = function() { this.rows = []; }; -var matchRegexp = /([A-Za-z]+) (\d+ )?(\d+)?/; +var matchRegexp = /([A-Za-z]+) ?(\d+ )?(\d+)?/; //adds a command complete message Result.prototype.addCommandComplete = function(msg) { diff --git a/test/integration/client/query-error-handling-tests.js b/test/integration/client/query-error-handling-tests.js index b110c98..8ac060e 100644 --- a/test/integration/client/query-error-handling-tests.js +++ b/test/integration/client/query-error-handling-tests.js @@ -21,7 +21,7 @@ test('error during query execution', function() { var killIdleQuery = "SELECT " + pidColName + ", (SELECT pg_terminate_backend(" + pidColName + ")) AS killed FROM pg_stat_activity WHERE " + queryColName + " = $1"; client2.query(killIdleQuery, [sleepQuery], assert.calls(function(err, res) { assert.ifError(err); - assert.equal(res.rowCount, 1); + assert.equal(res.rows.length, 1); client2.end(); assert.emits(client2, 'end'); })); diff --git a/test/integration/client/result-metadata-tests.js b/test/integration/client/result-metadata-tests.js index 98d065e..8f66fe1 100644 --- a/test/integration/client/result-metadata-tests.js +++ b/test/integration/client/result-metadata-tests.js @@ -5,29 +5,31 @@ test('should return insert metadata', function() { pg.connect(helper.config, assert.calls(function(err, client, done) { assert.isNull(err); - client.query("CREATE TEMP TABLE zugzug(name varchar(10))", assert.calls(function(err, result) { - assert.isNull(err); - assert.equal(result.oid, null); - assert.equal(result.command, 'CREATE'); + helper.versionGTE(client, '9.0.0', assert.success(function(hasRowCount) { + client.query("CREATE TEMP TABLE zugzug(name varchar(10))", assert.calls(function(err, result) { + assert.isNull(err); + assert.equal(result.oid, null); + assert.equal(result.command, 'CREATE'); - var q = client.query("INSERT INTO zugzug(name) VALUES('more work?')", assert.calls(function(err, result) { - assert.equal(result.command, "INSERT"); - assert.equal(result.rowCount, 1); - - client.query('SELECT * FROM zugzug', assert.calls(function(err, result) { - assert.isNull(err); + var q = client.query("INSERT INTO zugzug(name) VALUES('more work?')", assert.calls(function(err, result) { + assert.equal(result.command, "INSERT"); assert.equal(result.rowCount, 1); - assert.equal(result.command, 'SELECT'); - process.nextTick(pg.end.bind(pg)); + + client.query('SELECT * FROM zugzug', assert.calls(function(err, result) { + assert.isNull(err); + if(hasRowCount) assert.equal(result.rowCount, 1); + assert.equal(result.command, 'SELECT'); + process.nextTick(pg.end.bind(pg)); + })); })); + + assert.emits(q, 'end', function(result) { + assert.equal(result.command, "INSERT"); + if(hasRowCount) assert.equal(result.rowCount, 1); + done(); + }); + })); - - assert.emits(q, 'end', function(result) { - assert.equal(result.command, "INSERT"); - assert.equal(result.rowCount, 1); - done(); - }); - })); })); });