From 13455161174cbcfd20b4879373736ae563984e7c Mon Sep 17 00:00:00 2001 From: Ricky Ng-Adam Date: Fri, 25 Apr 2014 13:45:34 +0800 Subject: [PATCH 1/2] bump up timeout for tests against AWS from 5s to 15s --- .../integration/client/heroku-pgpass-tests.js | 23 +++++++++++-------- test/integration/client/heroku-ssl-tests.js | 19 ++++++++------- test/test-helper.js | 5 ++-- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/test/integration/client/heroku-pgpass-tests.js b/test/integration/client/heroku-pgpass-tests.js index c0379233..c7aeab9c 100644 --- a/test/integration/client/heroku-pgpass-tests.js +++ b/test/integration/client/heroku-pgpass-tests.js @@ -22,15 +22,18 @@ var config = { ssl: true }; -// connect & disconnect from heroku -pg.connect(config, assert.success(function(client, done) { - client.query('SELECT NOW() as time', assert.success(function(res) { - assert(res.rows[0].time.getTime()); +test('uses password file when PGPASSFILE env variable is set', function() { + // connect & disconnect from heroku + pg.connect(config, assert.calls(function(err, client, done) { + assert.isNull(err); + client.query('SELECT NOW() as time', assert.success(function(res) { + assert(res.rows[0].time.getTime()); - // cleanup ... remove the env variable - delete process.env.PGPASSFILE; + // cleanup ... remove the env variable + delete process.env.PGPASSFILE; - done(); - pg.end(); - })) -})); + done(); + pg.end(); + })) + }, 15000)); +}); diff --git a/test/integration/client/heroku-ssl-tests.js b/test/integration/client/heroku-ssl-tests.js index 5b6b87da..e012a098 100644 --- a/test/integration/client/heroku-ssl-tests.js +++ b/test/integration/client/heroku-ssl-tests.js @@ -15,11 +15,14 @@ var config = { ssl: true }; -//connect & disconnect from heroku -pg.connect(config, assert.success(function(client, done) { - client.query('SELECT NOW() as time', assert.success(function(res) { - assert(res.rows[0].time.getTime()); - done(); - pg.end(); - })) -})); +test('connection with config ssl = true', function() { + //connect & disconnect from heroku + pg.connect(config, assert.calls(function(err, client, done) { + assert.isNull(err); + client.query('SELECT NOW() as time', assert.success(function(res) { + assert(res.rows[0].time.getTime()); + done(); + pg.end(); + })) + }, 15000)); +}); \ No newline at end of file diff --git a/test/test-helper.js b/test/test-helper.js index 757b200b..0a1e94c1 100644 --- a/test/test-helper.js +++ b/test/test-helper.js @@ -133,9 +133,10 @@ assert.lengthIs = function(actual, expectedLength) { var expect = function(callback, timeout) { var executed = false; + timeout = timeout || 5000; var id = setTimeout(function() { - assert.ok(executed, "Expected execution of function to be fired"); - }, timeout || 5000) + assert.ok(executed, "Expected execution of function to be fired within " + timeout + ' milliseconds'); + }, timeout) if(callback.length < 3) { return function(err, queryResult) { From 8fb28c5cfe8a35d27f574ccf500733151e22ecdd Mon Sep 17 00:00:00 2001 From: Ricky Ng-Adam Date: Fri, 2 May 2014 12:32:15 +0800 Subject: [PATCH 2/2] test timeout value modifiable globally with TEST_TIMEOUT env variable --- test/integration/client/heroku-pgpass-tests.js | 2 +- test/integration/client/heroku-ssl-tests.js | 2 +- test/test-helper.js | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/test/integration/client/heroku-pgpass-tests.js b/test/integration/client/heroku-pgpass-tests.js index c7aeab9c..578342f1 100644 --- a/test/integration/client/heroku-pgpass-tests.js +++ b/test/integration/client/heroku-pgpass-tests.js @@ -35,5 +35,5 @@ test('uses password file when PGPASSFILE env variable is set', function() { done(); pg.end(); })) - }, 15000)); + })); }); diff --git a/test/integration/client/heroku-ssl-tests.js b/test/integration/client/heroku-ssl-tests.js index e012a098..f0f70074 100644 --- a/test/integration/client/heroku-ssl-tests.js +++ b/test/integration/client/heroku-ssl-tests.js @@ -24,5 +24,5 @@ test('connection with config ssl = true', function() { done(); pg.end(); })) - }, 15000)); + })); }); \ No newline at end of file diff --git a/test/test-helper.js b/test/test-helper.js index 0a1e94c1..acd092b4 100644 --- a/test/test-helper.js +++ b/test/test-helper.js @@ -133,9 +133,13 @@ assert.lengthIs = function(actual, expectedLength) { var expect = function(callback, timeout) { var executed = false; - timeout = timeout || 5000; + timeout = timeout || parseInt(process.env.TEST_TIMEOUT) || 5000; var id = setTimeout(function() { - assert.ok(executed, "Expected execution of function to be fired within " + timeout + ' milliseconds'); + assert.ok(executed, + "Expected execution of function to be fired within " + timeout + + " milliseconds " + + + " (hint: export TEST_TIMEOUT=" + + " to change timeout globally)"); }, timeout) if(callback.length < 3) {