heroku-debug
Version:
debugging plugin for the CLI
36 lines (30 loc) • 818 B
JavaScript
;
describe('ready_check', function () {
it('should retry when redis is not ready', function (done) {
var redis = new Redis({ lazyConnect: true });
stub(redis, 'info', function (callback) {
callback(null, 'loading:1\r\nloading_eta_seconds:7');
});
stub(global, 'setTimeout', function (body, ms) {
if (ms === 7000) {
redis.info.restore();
global.setTimeout.restore();
done();
}
});
redis.connect();
});
it('should reconnect when info return a error', function (done) {
var redis = new Redis({
lazyConnect: true,
retryStrategy: function () {
done();
return;
}
});
stub(redis, 'info', function (callback) {
callback(new Error('info error'));
});
redis.connect();
});
});