diff --git a/test/caching.unit.js b/test/caching.unit.js index 33837fd..de8a2ed 100644 --- a/test/caching.unit.js +++ b/test/caching.unit.js @@ -357,6 +357,23 @@ describe("caching", function () { }); }); + context("when an error is thrown in the work function", function () { + var fake_error; + + beforeEach(function() { + fake_error = new Error(support.random.string()); + }); + + it("bubbles up that error", function (done) { + cache.wrap(key, function () { + throw fake_error; + }, ttl, function (err) { + assert.equal(err, fake_error); + done(); + }); + }); + }); + context("when store.get() calls back with an error", function () { context("and ignoreCacheErrors is not set (default is false)", function () { it("bubbles up that error", function (done) { diff --git a/test/multi_caching.unit.js b/test/multi_caching.unit.js index 746c951..31688e0 100644 --- a/test/multi_caching.unit.js +++ b/test/multi_caching.unit.js @@ -449,6 +449,23 @@ describe("multi_caching", function () { memory_store.create.restore(); }); + context("when an error is thrown in the work function", function () { + var fake_error; + + beforeEach(function() { + fake_error = new Error(support.random.string()); + }); + + it("bubbles up that error", function (done) { + multi_cache.wrap(key, function () { + throw fake_error; + }, ttl, function (err) { + assert.equal(err, fake_error); + done(); + }); + }); + }); + context("when store.get() calls back with an error", function () { it("bubbles up that error", function (done) { var fake_error = new Error(support.random.string());