CartoDB-SQL-API/test/unit/health-check-test.js
Daniel García Aubert 5a96dbb59c Run eslint --fix
2019-12-23 18:19:08 +01:00

46 lines
1.2 KiB
JavaScript

'use strict';
require('../helper');
var assert = require('assert');
var HealthCheck = require('../../lib/monitoring/health-check');
var metadataBackend = {};
function PSQL (dbParams) {
this.params = dbParams;
}
var healthCheck = new HealthCheck(metadataBackend, PSQL);
describe('health checks', function () {
it('errors if disabled file exists', function (done) {
var fs = require('fs');
var readFileFn = fs.readFile;
fs.readFile = function (filename, callback) {
callback(null, 'Maintenance');
};
healthCheck.check(function (err) {
assert.equal(err.message, 'Maintenance');
assert.equal(err.http_status, 503);
fs.readFile = readFileFn;
done();
});
});
it('does not err if disabled file does not exists', function (done) {
var fs = require('fs');
var readFileFn = fs.readFile;
fs.readFile = function (filename, callback) {
callback(new Error('ENOENT'), null);
};
healthCheck.check(function (err) {
assert.equal(err, null);
fs.readFile = readFileFn;
done();
});
});
});