From 21cbdfd4a30b76e9044f006ce707a5b6ba3fbf5a Mon Sep 17 00:00:00 2001 From: Luis Bosque Date: Mon, 6 Apr 2015 16:44:01 +0200 Subject: [PATCH] Disable per user health checks tests --- test/acceptance/health_check.js | 76 +++++++++++----------- test/unit/health_check.js | 108 ++++++++++++++++---------------- 2 files changed, 92 insertions(+), 92 deletions(-) diff --git a/test/acceptance/health_check.js b/test/acceptance/health_check.js index d19a319c..396a6dec 100644 --- a/test/acceptance/health_check.js +++ b/test/acceptance/health_check.js @@ -10,9 +10,9 @@ suite('health checks', function() { beforeEach(function(done) { global.settings.health = { - enabled: true, - username: 'vizzuality', - query: 'select 1::text' + enabled: true + //username: 'vizzuality', + //query: 'select 1::text' }; done(); }); @@ -65,52 +65,52 @@ suite('health checks', function() { ); }); - test('fails for invalid user because it is not in redis', function(done) { - global.settings.health.username = 'invalid'; + //test('fails for invalid user because it is not in redis', function(done) { + // global.settings.health.username = 'invalid'; - assert.response(app, - healthCheckRequest, - { - status: 503 - }, - function(res, err) { - assert.ok(!err); + // assert.response(app, + // healthCheckRequest, + // { + // status: 503 + // }, + // function(res, err) { + // assert.ok(!err); - var parsed = JSON.parse(res.body); + // var parsed = JSON.parse(res.body); - assert.equal(parsed.enabled, true); - assert.equal(parsed.ok, false); + // assert.equal(parsed.enabled, true); + // assert.equal(parsed.ok, false); - assert.equal(parsed.result.redis.ok, false); + // assert.equal(parsed.result.redis.ok, false); - done(); - } - ); - }); + // done(); + // } + // ); + //}); - test('fails for wrong query', function(done) { - global.settings.health.query = 'select wadus query'; + //test('fails for wrong query', function(done) { + // global.settings.health.query = 'select wadus query'; - assert.response(app, - healthCheckRequest, - { - status: 503 - }, - function(res, err) { - assert.ok(!err); + // assert.response(app, + // healthCheckRequest, + // { + // status: 503 + // }, + // function(res, err) { + // assert.ok(!err); - var parsed = JSON.parse(res.body); + // var parsed = JSON.parse(res.body); - assert.equal(parsed.enabled, true); - assert.equal(parsed.ok, false); + // assert.equal(parsed.enabled, true); + // assert.equal(parsed.ok, false); - assert.ok(parsed.result.redis.ok); + // assert.ok(parsed.result.redis.ok); - assert.equal(parsed.result.postgresql.ok, false); + // assert.equal(parsed.result.postgresql.ok, false); - done(); - } - ); - }); + // done(); + // } + // ); + //}); }); diff --git a/test/unit/health_check.js b/test/unit/health_check.js index fb4a5b80..d56b6402 100644 --- a/test/unit/health_check.js +++ b/test/unit/health_check.js @@ -14,65 +14,65 @@ var healthCheck = new HealthCheck(metadataBackend, PSQL); suite('health checks', function() { - beforeEach(function(done) { - mockGetAllUserDBParams(function(username, callback) { - callback(null, {user: 'fake', dbname: 'fake'}); - }); + //beforeEach(function(done) { + // mockGetAllUserDBParams(function(username, callback) { + // callback(null, {user: 'fake', dbname: 'fake'}); + // }); - mockQuery(function(query, callback) { - callback(null, {rows: [{},{},{}]}); - }); + // mockQuery(function(query, callback) { + // callback(null, {rows: [{},{},{}]}); + // }); - done(); - }); + // done(); + //}); - test('happy case, everything goes OK', function(done) { - healthCheck.check('fake', 'select 1::text', function(err, result) { - assert.ok(result.redis.ok); - assert.ok(result.redis.elapsed >= 0); - assert.equal(result.redis.count, 2); + //test('happy case, everything goes OK', function(done) { + // healthCheck.check('fake', 'select 1::text', function(err, result) { + // assert.ok(result.redis.ok); + // assert.ok(result.redis.elapsed >= 0); + // assert.equal(result.redis.count, 2); - assert.ok(result.postgresql.ok); - assert.ok(result.postgresql.elapsed >= 0); - assert.ok(result.postgresql.count, 3); + // assert.ok(result.postgresql.ok); + // assert.ok(result.postgresql.elapsed >= 0); + // assert.ok(result.postgresql.count, 3); - done(); - }); - }); + // done(); + // }); + //}); - test('error in metadataBackend reports as false and does not report postgresql except ok=false', function(done) { - mockGetAllUserDBParams(function() { - throw "Error"; - }); - healthCheck.check('fake', 'select 1::text', function(err, result) { - assert.equal(result.redis.ok, false); - assert.ok(result.redis.elapsed >= 0); - assert.ok(_.isUndefined(result.redis.count)); + //test('error in metadataBackend reports as false and does not report postgresql except ok=false', function(done) { + // mockGetAllUserDBParams(function() { + // throw "Error"; + // }); + // healthCheck.check('fake', 'select 1::text', function(err, result) { + // assert.equal(result.redis.ok, false); + // assert.ok(result.redis.elapsed >= 0); + // assert.ok(_.isUndefined(result.redis.count)); - assert.equal(result.postgresql.ok, false); - assert.ok(_.isUndefined(result.postgresql.elapsed)); - assert.ok(_.isUndefined(result.postgresql.count)); + // assert.equal(result.postgresql.ok, false); + // assert.ok(_.isUndefined(result.postgresql.elapsed)); + // assert.ok(_.isUndefined(result.postgresql.count)); - done(); - }); - }); + // done(); + // }); + //}); - test('error in metadataBackend reports as false and does not report postgresql except ok=false', function(done) { - mockQuery(function() { - throw "Error"; - }); - healthCheck.check('fake', 'select 1::text', function(err, result) { - assert.ok(result.redis.ok); - assert.ok(result.redis.elapsed >= 0); - assert.equal(result.redis.count, 2); + //test('error in metadataBackend reports as false and does not report postgresql except ok=false', function(done) { + // mockQuery(function() { + // throw "Error"; + // }); + // healthCheck.check('fake', 'select 1::text', function(err, result) { + // assert.ok(result.redis.ok); + // assert.ok(result.redis.elapsed >= 0); + // assert.equal(result.redis.count, 2); - assert.equal(result.postgresql.ok, false); - assert.ok(_.isUndefined(result.postgresql.elapsed)); - assert.ok(_.isUndefined(result.postgresql.count)); + // assert.equal(result.postgresql.ok, false); + // assert.ok(_.isUndefined(result.postgresql.elapsed)); + // assert.ok(_.isUndefined(result.postgresql.count)); - done(); - }); - }); + // done(); + // }); + //}); test('error if disabled file exists', function(done) { var fs = require('fs'); @@ -103,11 +103,11 @@ suite('health checks', function() { }); }); - function mockGetAllUserDBParams(func) { - metadataBackend.getAllUserDBParams = func; - } + //function mockGetAllUserDBParams(func) { + // metadataBackend.getAllUserDBParams = func; + //} - function mockQuery(func) { - PSQL.prototype.query = func; - } + //function mockQuery(func) { + // PSQL.prototype.query = func; + //} });