Browse Source

testing that we can pass in a a store module

hotfix/0.7.1
Bryan Donovan 12 years ago
parent
commit
275bcb00f4
  1. 4
      lib/caching.js
  2. 12
      test/caching.unit.js

4
lib/caching.js

@ -2,7 +2,11 @@ var caching = function (args) {
args = args || {};
var self = {};
if (typeof args.store === 'object') {
if (args.store.create) {
self.store = args.store.create(args);
} else {
self.store = args.store;
}
} else if (typeof args.store === 'string' && args.store.match(/\//)) {
self.store = require(args.store).create(args);
} else {

12
test/caching.unit.js

@ -348,5 +348,17 @@ describe("caching", function () {
});
});
});
it("allows us to pass in a module (uninstantiated)", function (done) {
var store = memory_store;
cache = caching({store: store});
cache.set(key, value, function (err) {
check_err(err);
cache.get(key, function (err, result) {
assert.equal(result, value);
done();
});
});
});
});
});

Loading…
Cancel
Save