diff --git a/test/integration/client/json-type-parsing-tests.js b/test/integration/client/json-type-parsing-tests.js index 1c0759b..d216aef 100644 --- a/test/integration/client/json-type-parsing-tests.js +++ b/test/integration/client/json-type-parsing-tests.js @@ -9,7 +9,7 @@ if (helper.config.binary) { test('can read and write json', function() { helper.pg.connect(helper.config, function(err, client, done) { assert.ifError(err); - helper.versionGTE(client, '9.2.0', assert.success(function(jsonSupported) { + helper.versionGTE(client, '90200', assert.success(function(jsonSupported) { if(!jsonSupported) { console.log('skip json test on older versions of postgres'); done(); diff --git a/test/integration/client/query-error-handling-prepared-statement-tests.js b/test/integration/client/query-error-handling-prepared-statement-tests.js index 77615ff..c9bb260 100644 --- a/test/integration/client/query-error-handling-prepared-statement-tests.js +++ b/test/integration/client/query-error-handling-prepared-statement-tests.js @@ -6,7 +6,7 @@ function killIdleQuery(targetQuery) { var pidColName = 'procpid' var queryColName = 'current_query'; client2.connect(assert.success(function() { - helper.versionGTE(client2, '9.2.0', assert.success(function(isGreater) { + helper.versionGTE(client2, '90200', assert.success(function(isGreater) { if(isGreater) { pidColName = 'pid'; queryColName = 'query'; diff --git a/test/integration/client/query-error-handling-tests.js b/test/integration/client/query-error-handling-tests.js index 2618a49..e7bd56a 100644 --- a/test/integration/client/query-error-handling-tests.js +++ b/test/integration/client/query-error-handling-tests.js @@ -7,7 +7,7 @@ test('error during query execution', function() { var sleepQuery = 'select pg_sleep(5)'; var pidColName = 'procpid' var queryColName = 'current_query'; - helper.versionGTE(client, '9.2.0', assert.success(function(isGreater) { + helper.versionGTE(client, 90200, assert.success(function(isGreater) { if(isGreater) { pidColName = 'pid'; queryColName = 'query'; @@ -43,7 +43,7 @@ if(helper.config.native) return; test('9.3 column error fields', function() { var client = new Client(helper.args); client.connect(assert.success(function() { - helper.versionGTE(client, '9.3.0', assert.success(function(isGreater) { + helper.versionGTE(client, 90300, assert.success(function(isGreater) { if(!isGreater) { return client.end(); } @@ -65,7 +65,7 @@ test('9.3 column error fields', function() { test('9.3 constraint error fields', function() { var client = new Client(helper.args); client.connect(assert.success(function() { - helper.versionGTE(client, '9.3.0', assert.success(function(isGreater) { + helper.versionGTE(client, 90300, assert.success(function(isGreater) { if(!isGreater) { console.log('skip 9.3 error field on older versions of postgres'); return client.end(); diff --git a/test/integration/client/result-metadata-tests.js b/test/integration/client/result-metadata-tests.js index 0136300..b9d09b5 100644 --- a/test/integration/client/result-metadata-tests.js +++ b/test/integration/client/result-metadata-tests.js @@ -5,7 +5,7 @@ test('should return insert metadata', function() { pg.connect(helper.config, assert.calls(function(err, client, done) { assert.isNull(err); - helper.versionGTE(client, '9.0.0', assert.success(function(hasRowCount) { + helper.versionGTE(client, '90000', 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); diff --git a/test/integration/connection-pool/error-tests.js b/test/integration/connection-pool/error-tests.js index 59121a8..27525bf 100644 --- a/test/integration/connection-pool/error-tests.js +++ b/test/integration/connection-pool/error-tests.js @@ -11,7 +11,7 @@ pg.connect(helper.config, assert.success(function(client, done) { pg.connect(helper.config, assert.success(function(client2, done2) { client2.id = 2; var pidColName = 'procpid'; - helper.versionGTE(client2, '9.2.0', assert.success(function(isGreater) { + helper.versionGTE(client2, '90200', assert.success(function(isGreater) { var killIdleQuery = 'SELECT pid, (SELECT pg_terminate_backend(pid)) AS killed FROM pg_stat_activity WHERE state = $1'; var params = ['idle']; if(!isGreater) { diff --git a/test/integration/test-helper.js b/test/integration/test-helper.js index c6a4922..155c360 100644 --- a/test/integration/test-helper.js +++ b/test/integration/test-helper.js @@ -13,14 +13,13 @@ helper.client = function(cb) { return client; }; -var semver = require('semver'); -helper.versionGTE = function(client, versionString, callback) { - client.query('SELECT version()', assert.calls(function(err, result) { - if(err) return callback(err); - var version = result.rows[0].version.split(' ')[1]; - return callback(null, semver.gte(version, versionString)); - })); -}; +helper.versionGTE = function (client, testVersion, callback) { + client.query('SHOW server_version_num', assert.calls(function (err, result) { + if (err) return callback(err) + var version = parseInt(result.rows[0].server_version_num, 10) + return callback(null, version >= testVersion) + })) +} //export parent helper stuffs module.exports = helper;