diff options
author | Bojan Djurkovic <dbojan@gmail.com> | 2016-08-02 12:55:26 -0300 |
---|---|---|
committer | Bojan Djurkovic <dbojan@gmail.com> | 2016-08-02 12:55:26 -0300 |
commit | cbc5b4f864f621fe6068a6455faca2c06418c90f (patch) | |
tree | 3dd07a8adffc7093be8668c0826ccc59aed66480 /mocha_test/retryable.js | |
parent | 60dc3b658e4c6bdc8a2469e278a474e1586fa74a (diff) | |
download | async-cbc5b4f864f621fe6068a6455faca2c06418c90f.tar.gz |
add filter option to retry() and retryable() to allow for error filtering and control of retry flow. Resolves #1256.
Diffstat (limited to 'mocha_test/retryable.js')
-rw-r--r-- | mocha_test/retryable.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/mocha_test/retryable.js b/mocha_test/retryable.js index 7147269..0a229f5 100644 --- a/mocha_test/retryable.js +++ b/mocha_test/retryable.js @@ -21,6 +21,30 @@ describe('retryable', function () { }, 15); }); + it('basics with filter function', function (done) { + var calls = 0; + var special = 'special'; + var opts = { + filter: function(err) { + return err == special; + } + }; + var retryableTask = async.retryable(opts, function (arg, cb) { + calls++; + expect(arg).to.equal(42); + cb(calls === 3 ? 'fail' : special); + }); + + retryableTask(42, function (err) { + expect(err).to.equal('fail'); + expect(calls).to.equal(3); + done(); + }); + + setTimeout(function () { + }, 15); + }); + it('should work as an embedded task', function(done) { var retryResult = 'RETRY'; var fooResults; |