CartoDB-SQL-API/test/acceptance/health_check.js
Raul Ochoa f92d50cccf Rename from app to server
Removes app_root dependency in requires
2016-09-14 20:54:53 +02:00

67 lines
1.5 KiB
JavaScript

require('../helper');
require('../support/assert');
var assert = require('assert');
var server = require('../../app/server')();
describe('health checks', function() {
beforeEach(function(done) {
global.settings.health = {
enabled: true
//username: 'vizzuality',
//query: 'select 1::text'
};
done();
});
var healthCheckRequest = {
url: '/api/v1/health',
method: 'GET',
headers: {
host: 'vizzuality.localhost'
}
};
it('returns 200 and ok=true with disabled configuration', function(done) {
global.settings.health.enabled = false;
assert.response(server,
healthCheckRequest,
{
status: 200
},
function(res, err) {
assert.ok(!err);
var parsed = JSON.parse(res.body);
assert.equal(parsed.enabled, false);
assert.ok(parsed.ok);
done();
}
);
});
it('returns 200 and ok=true with enabled configuration', function(done) {
assert.response(server,
healthCheckRequest,
{
status: 200
},
function(res, err) {
assert.ok(!err);
var parsed = JSON.parse(res.body);
assert.ok(parsed.enabled);
assert.ok(parsed.ok);
done();
}
);
});
});