CartoDB-SQL-API/test/acceptance/health_check.js

67 lines
1.5 KiB
JavaScript
Raw Normal View History

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');
var server = require('../../app/server')();
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(server,
2014-08-27 23:09:59 +08:00
healthCheckRequest,
2014-08-27 00:40:58 +08:00
{
status: 200
},
function(err, res) {
2014-08-27 00:40:58 +08:00
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) {
assert.response(server,
2014-08-27 23:09:59 +08:00
healthCheckRequest,
2014-08-27 00:40:58 +08:00
{
status: 200
},
function(err, res) {
2014-08-27 00:40:58 +08:00
assert.ok(!err);
var parsed = JSON.parse(res.body);
assert.ok(parsed.enabled);
assert.ok(parsed.ok);
done();
}
);
});
});