Health check will always return error if file is found even if empty
This commit is contained in:
parent
ac7b02a434
commit
b617bb0277
@ -10,8 +10,8 @@ module.exports = HealthCheck;
|
||||
HealthCheck.prototype.check = function(callback) {
|
||||
fs.readFile(this.disableFile, function handleDisabledFile(err, data) {
|
||||
var disabledError = null;
|
||||
if (!!data) {
|
||||
disabledError = new Error(data);
|
||||
if (!err) {
|
||||
disabledError = new Error(data || 'Unknown error');
|
||||
disabledError.http_status = 503;
|
||||
}
|
||||
return callback(disabledError);
|
||||
|
@ -76,21 +76,21 @@ describe('health checks', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('no error if disabled file exists but has no content', function(done) {
|
||||
it('error if disabled file exists but has no content', function(done) {
|
||||
var readFileFn = fs.readFile;
|
||||
fs.readFile = function(filename, callback) {
|
||||
callback(null, '');
|
||||
};
|
||||
var server = new CartodbWindshaft(serverOptions);
|
||||
|
||||
assert.response(server, healthCheckRequest, RESPONSE_OK, function(res, err) {
|
||||
assert.response(server, healthCheckRequest, RESPONSE_FAIL, function(res, err) {
|
||||
fs.readFile = readFileFn;
|
||||
|
||||
assert.ok(!err);
|
||||
var parsed = JSON.parse(res.body);
|
||||
|
||||
assert.equal(parsed.enabled, true);
|
||||
assert.equal(parsed.ok, true);
|
||||
assert.ok(parsed.enabled);
|
||||
assert.ok(!parsed.ok);
|
||||
assert.equal(parsed.err, 'Unknown error');
|
||||
|
||||
done();
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user