Browse Source

Unit tests for thrown errors in the work function.

feature/nested-cache-fetch-fix
Alejandro Torrado 10 years ago
parent
commit
a6cb2983b8
  1. 17
      test/caching.unit.js
  2. 17
      test/multi_caching.unit.js

17
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("when store.get() calls back with an error", function () {
context("and ignoreCacheErrors is not set (default is false)", function () { context("and ignoreCacheErrors is not set (default is false)", function () {
it("bubbles up that error", function (done) { it("bubbles up that error", function (done) {

17
test/multi_caching.unit.js

@ -449,6 +449,23 @@ describe("multi_caching", function () {
memory_store.create.restore(); 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 () { context("when store.get() calls back with an error", function () {
it("bubbles up that error", function (done) { it("bubbles up that error", function (done) {
var fake_error = new Error(support.random.string()); var fake_error = new Error(support.random.string());

Loading…
Cancel
Save