From 537e8e763e4e5f500be469c4ac567e4584a7a940 Mon Sep 17 00:00:00 2001 From: bmc Date: Mon, 22 Apr 2013 10:26:43 -0500 Subject: [PATCH] Skip JSON tests on older versions of postgres --- .../client/json-type-parsing-tests.js | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/test/integration/client/json-type-parsing-tests.js b/test/integration/client/json-type-parsing-tests.js index 300f093f..1c0759bf 100644 --- a/test/integration/client/json-type-parsing-tests.js +++ b/test/integration/client/json-type-parsing-tests.js @@ -9,23 +9,30 @@ if (helper.config.binary) { test('can read and write json', function() { helper.pg.connect(helper.config, function(err, client, done) { assert.ifError(err); - client.query('CREATE TEMP TABLE stuff(id SERIAL PRIMARY KEY, data JSON)'); - var value ={name: 'Brian', age: 250, alive: true, now: new Date()}; - client.query('INSERT INTO stuff (data) VALUES ($1)', [value]); - client.query('SELECT * FROM stuff', assert.success(function(result) { - assert.equal(result.rows.length, 1); - assert.equal(typeof result.rows[0].data, 'object'); - var row = result.rows[0].data; - assert.strictEqual(row.name, value.name); - assert.strictEqual(row.age, value.age); - assert.strictEqual(row.alive, value.alive); - test('row should have "now" as a date', function() { - return false; - assert(row.now instanceof Date, 'row.now should be a date instance but is ' + typeof row.now); - }); - assert.equal(JSON.stringify(row.now), JSON.stringify(value.now)); - done(); - helper.pg.end(); + helper.versionGTE(client, '9.2.0', assert.success(function(jsonSupported) { + if(!jsonSupported) { + console.log('skip json test on older versions of postgres'); + done(); + return helper.pg.end(); + } + client.query('CREATE TEMP TABLE stuff(id SERIAL PRIMARY KEY, data JSON)'); + var value ={name: 'Brian', age: 250, alive: true, now: new Date()}; + client.query('INSERT INTO stuff (data) VALUES ($1)', [value]); + client.query('SELECT * FROM stuff', assert.success(function(result) { + assert.equal(result.rows.length, 1); + assert.equal(typeof result.rows[0].data, 'object'); + var row = result.rows[0].data; + assert.strictEqual(row.name, value.name); + assert.strictEqual(row.age, value.age); + assert.strictEqual(row.alive, value.alive); + test('row should have "now" as a date', function() { + return false; + assert(row.now instanceof Date, 'row.now should be a date instance but is ' + typeof row.now); + }); + assert.equal(JSON.stringify(row.now), JSON.stringify(value.now)); + done(); + helper.pg.end(); + })); })); }); });