2014-08-27 00:40:58 +08:00
|
|
|
require('../helper');
|
|
|
|
require('../support/assert');
|
|
|
|
|
2015-05-13 17:21:44 +08:00
|
|
|
var assert = require('assert');
|
2015-12-04 01:33:17 +08:00
|
|
|
var app = require(global.settings.app_root + '/app/app')();
|
2014-08-27 00:40:58 +08:00
|
|
|
|
2015-05-13 17:21:44 +08:00
|
|
|
describe('health checks', function() {
|
2014-08-27 00:40:58 +08:00
|
|
|
|
|
|
|
beforeEach(function(done) {
|
|
|
|
global.settings.health = {
|
2015-04-06 22:44:01 +08:00
|
|
|
enabled: true
|
|
|
|
//username: 'vizzuality',
|
|
|
|
//query: 'select 1::text'
|
2014-08-27 00:40:58 +08:00
|
|
|
};
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
|
2014-08-27 23:09:59 +08:00
|
|
|
var healthCheckRequest = {
|
|
|
|
url: '/api/v1/health',
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
host: 'vizzuality.localhost'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-05-13 17:21:44 +08:00
|
|
|
it('returns 200 and ok=true with disabled configuration', function(done) {
|
2014-08-27 00:40:58 +08:00
|
|
|
global.settings.health.enabled = false;
|
|
|
|
|
|
|
|
assert.response(app,
|
2014-08-27 23:09:59 +08:00
|
|
|
healthCheckRequest,
|
2014-08-27 00:40:58 +08:00
|
|
|
{
|
|
|
|
status: 200
|
|
|
|
},
|
|
|
|
function(res, err) {
|
|
|
|
assert.ok(!err);
|
|
|
|
|
|
|
|
var parsed = JSON.parse(res.body);
|
|
|
|
|
|
|
|
assert.equal(parsed.enabled, false);
|
|
|
|
assert.ok(parsed.ok);
|
|
|
|
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2015-05-13 17:21:44 +08:00
|
|
|
it('returns 200 and ok=true with enabled configuration', function(done) {
|
2014-08-27 00:40:58 +08:00
|
|
|
assert.response(app,
|
2014-08-27 23:09:59 +08:00
|
|
|
healthCheckRequest,
|
2014-08-27 00:40:58 +08:00
|
|
|
{
|
|
|
|
status: 200
|
|
|
|
},
|
|
|
|
function(res, err) {
|
|
|
|
assert.ok(!err);
|
|
|
|
|
|
|
|
var parsed = JSON.parse(res.body);
|
|
|
|
|
|
|
|
assert.ok(parsed.enabled);
|
|
|
|
assert.ok(parsed.ok);
|
|
|
|
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|