lru-cache-for-clusters-as-promised
Advanced tools
Comparing version 1.3.0 to 1.3.1
{ | ||
"name": "lru-cache-for-clusters-as-promised", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "LRU Cache that is safe for clusters", | ||
@@ -39,7 +39,7 @@ "main": "./lru-cache-for-clusters-as-promised.js", | ||
"eslint-plugin-import": "^1.16.0", | ||
"eslint-plugin-jsx-a11y": "^2.2.2", | ||
"eslint-plugin-mocha": "^4.5.1", | ||
"eslint-plugin-react": "^6.3.0", | ||
"eslint-plugin-jsx-a11y": "^2.2.3", | ||
"eslint-plugin-mocha": "^4.6.0", | ||
"eslint-plugin-react": "^6.4.0", | ||
"express": "^4.14.0", | ||
"should": "^11.1.0", | ||
"should": "^11.1.1", | ||
"supertest": "^2.0.0" | ||
@@ -51,3 +51,6 @@ }, | ||
"depcheck" | ||
], | ||
"pre-push": [ | ||
"test" | ||
] | ||
} |
const request = require('supertest'); | ||
const should = require('should'); | ||
const config = require('./lib/config'); | ||
const TestUtils = require('./lib/test-utils'); | ||
let master = null; | ||
describe('LRU Cache for Clusters', () => { | ||
const testUtils = new TestUtils(); | ||
// run before the tests start | ||
@@ -16,44 +18,2 @@ before((done) => { | ||
.get('/reset') | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
should(response.text).equal('{"result":0}'); | ||
return done(); | ||
}); | ||
}); | ||
it('should timeout', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/timeout') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
response.text.should.eql('ok'); | ||
return done(); | ||
}); | ||
}); | ||
it('should timeout with reject', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/reject') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
response.text.should.eql('ok'); | ||
return done(); | ||
}); | ||
}); | ||
it('should set(key, value)', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/set') | ||
.expect(200) | ||
.end((err) => { | ||
@@ -67,226 +27,16 @@ if (err) { | ||
it('should get(key)', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/get') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
response.text.should.equal(config.args.one); | ||
return done(); | ||
}); | ||
}); | ||
it('should del(key)', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/del') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
should(response.text).be.empty(null); | ||
return done(); | ||
}); | ||
}); | ||
it('should incr(key)', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/incr') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
should(response.text).eql('[1,2]'); | ||
return done(); | ||
}); | ||
}); | ||
it('should incr(key, 2)', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/incr2') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
should(response.text).eql('[2,4]'); | ||
return done(); | ||
}); | ||
}); | ||
it('should decr(key)', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/decr') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
should(response.text).eql('[-1,-2]'); | ||
return done(); | ||
}); | ||
}); | ||
it('should decr(key, 2)', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/decr2') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
should(response.text).eql('[-2,-4]'); | ||
return done(); | ||
}); | ||
}); | ||
it('should add four keys and have the first fall out', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/one-two-three-four') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
should(response.text).be.empty(); | ||
return done(); | ||
}); | ||
}); | ||
it('should add four keys and then access the first so the second falls out', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/one-two-three-four-one') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
should(response.text).be.equal(config.args.one); | ||
return done(); | ||
}); | ||
}); | ||
it('should peek(key)', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/peek') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
should(response.text).equal('["one",null]'); | ||
return done(); | ||
}); | ||
}); | ||
it('should has(key)', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/has') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
should(response.text).be.equal('true'); | ||
return done(); | ||
}); | ||
}); | ||
it('should return length/itemCount', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/length-itemcount') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
should(response.text).be.equal('[1,1]'); | ||
return done(); | ||
}); | ||
}); | ||
it('should reset the cache', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/reset') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
should(response.text).be.equal('{"result":0}'); | ||
return done(); | ||
}); | ||
}); | ||
it('should return keys/values', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/keys-values') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
should(response.text).equal('[["one"],["one"]]'); | ||
return done(); | ||
}); | ||
}); | ||
it('should prune the cache', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/prune') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
should(response.text).equal('{"result":1}'); | ||
return done(); | ||
}); | ||
}); | ||
it('should dump the cache', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/dump') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
should(response.text).equal('{"result":[{"k":"one","v":"one","e":0}]}'); | ||
return done(); | ||
}); | ||
}); | ||
it('should max the cache', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/max') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
should(response.text).equal('[3,10]'); | ||
return master.getCacheMax() | ||
.then((masterMax) => { | ||
should(masterMax).equal(10); | ||
return done(); | ||
['tests', 'clusterTests'].forEach((test) => { | ||
Object.keys(testUtils[test]).forEach((method) => { | ||
it(`should ${testUtils[test][method]}`, (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get(`/${method}`) | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
response.body.should.equal(true); | ||
return done(); | ||
}); | ||
}); | ||
@@ -296,52 +46,2 @@ }); | ||
it('should maxAge the cache', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/maxAge') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
should(response.text).equal('[0,100]'); | ||
return master.getCacheMaxAge() | ||
.then((masterMaxAge) => { | ||
should(masterMaxAge).equal(100); | ||
return done(); | ||
}); | ||
}); | ||
}); | ||
it('should stale the cache', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/stale') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
should(response.text).equal('[null,true]'); | ||
return master.getCacheStale() | ||
.then((masterStale) => { | ||
should(masterStale).equal(true); | ||
return done(); | ||
}); | ||
}); | ||
}); | ||
it('should not respond to messages that are from somewhere else', (done) => { | ||
// run the request | ||
request(`http://${config.server.host}:${config.server.port}`) | ||
.get('/hi') | ||
.expect(200) | ||
.end((err, response) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
should(response.text).equal('hello'); | ||
return done(); | ||
}); | ||
}); | ||
it('should access the shared cache from the master thread', (done) => { | ||
@@ -348,0 +48,0 @@ master.accessSharedFromMaster(done); |
@@ -1,7 +0,8 @@ | ||
const http = require('http'); | ||
const config = require('./config'); | ||
const express = require('express'); | ||
const http = require('http'); | ||
const LRUCache = require('../../'); | ||
const TestUtils = require('./test-utils'); | ||
// this will be the SAME cache no matter what module calls it. | ||
// this will be the SAME cache no matter which module calls it. | ||
const defaultCache = new LRUCache({ | ||
@@ -18,217 +19,16 @@ max: 1, | ||
const testUtils = new TestUtils(cache); | ||
// create Express App | ||
const app = express(); | ||
// test non-caching messages | ||
app.get('/hi', (req, res) => { | ||
let responded = false; | ||
const callback = (response) => { | ||
if (!responded) { | ||
responded = true; | ||
res.send(response); | ||
} | ||
}; | ||
process.on('message', response => callback && callback(response)); | ||
process.send('hi'); | ||
}); | ||
app.get('/timeout', (req, res) => { | ||
const cacheBad = new LRUCache({ | ||
max: 3, | ||
stale: false, | ||
timeout: 1, | ||
namespace: 'bad-cache', | ||
}); | ||
return cacheBad.get('test') | ||
.then(result => res.send(result === undefined ? 'ok' : 'fail')); | ||
}); | ||
app.get('/reject', (req, res) => { | ||
const cacheBad = new LRUCache({ | ||
max: 3, | ||
stale: false, | ||
timeout: 1, | ||
failsafe: 'reject', | ||
namespace: 'bad-cache-reject', | ||
}); | ||
let large = '1234567890'; | ||
for (let i = 0; i < 17; i += 1) { | ||
large += large; | ||
} | ||
return cacheBad.get(`bad-cache-key-${large}`) | ||
.then(() => res.send('fail')) | ||
.catch(() => res.send('ok')); | ||
}); | ||
app.get('/set', (req, res) => { | ||
cache.set(config.args.one, config.args.one) | ||
.then(result => res.send(result)); | ||
}); | ||
app.get('/get', (req, res) => { | ||
cache.set(config.args.one, config.args.one) | ||
.then(() => cache.get(config.args.one)) | ||
.then(result => res.send(result)); | ||
}); | ||
app.get('/del', (req, res) => { | ||
cache.del(config.args.one) | ||
.then(() => cache.get(config.args.one)) | ||
.then(result => res.send(result)) | ||
.catch(err => res.send(err)); | ||
}); | ||
app.get('/incr', (req, res) => { | ||
const values = []; | ||
return cache.incr(config.args.one) | ||
.then((value) => { | ||
values.push(value); | ||
return cache.incr(config.args.one); | ||
}) | ||
.then((value) => { | ||
values.push(value); | ||
res.send(values); | ||
}); | ||
}); | ||
app.get('/incr2', (req, res) => { | ||
const values = []; | ||
const amount = 2; | ||
return cache.incr(config.args.one, amount) | ||
.then((value) => { | ||
values.push(value); | ||
return cache.incr(config.args.one, amount); | ||
}) | ||
.then((value) => { | ||
values.push(value); | ||
res.send(values); | ||
}); | ||
}); | ||
app.get('/decr', (req, res) => { | ||
const values = []; | ||
return cache.decr(config.args.one) | ||
.then((value) => { | ||
values.push(value); | ||
return cache.decr(config.args.one); | ||
}) | ||
.then((value) => { | ||
values.push(value); | ||
res.send(values); | ||
}); | ||
}); | ||
app.get('/decr2', (req, res) => { | ||
const values = []; | ||
const amount = 2; | ||
return cache.decr(config.args.one, amount) | ||
.then((value) => { | ||
values.push(value); | ||
return cache.decr(config.args.one, amount); | ||
}) | ||
.then((value) => { | ||
values.push(value); | ||
res.send(values); | ||
}); | ||
}); | ||
app.get('/one-two-three-four', (req, res) => { | ||
cache.set(config.args.one, config.args.one) | ||
.then(() => cache.set(config.args.two, config.args.two)) | ||
.then(() => cache.set(config.args.three, config.args.three)) | ||
.then(() => cache.set(config.args.four, config.args.four)) | ||
.then(() => cache.get(config.args.one)) | ||
.then(result => res.send(result)); | ||
}); | ||
app.get('/one-two-three-four-one', (req, res) => { | ||
cache.set(config.args.one, config.args.one) | ||
.then(() => cache.set(config.args.two, config.args.two)) | ||
.then(() => cache.set(config.args.three, config.args.three)) | ||
.then(() => cache.get(config.args.one)) | ||
.then(() => cache.set(config.args.four, config.args.four)) | ||
.then(() => cache.get(config.args.one)) | ||
.then(result => res.send(result)); | ||
}); | ||
app.get('/peek', (req, res) => { | ||
const vals = []; | ||
cache.set(config.args.one, config.args.one) | ||
.then(() => cache.set(config.args.two, config.args.two)) | ||
.then(() => cache.set(config.args.three, config.args.three)) | ||
.then(() => cache.peek(config.args.one)) | ||
.then((result) => { | ||
vals.push(result); | ||
return cache.set(config.args.four, config.args.four); | ||
}) | ||
.then(() => cache.get(config.args.one)) | ||
.then((result) => { | ||
vals.push(result); | ||
return res.send(vals); | ||
}); | ||
}); | ||
app.get('/has', (req, res) => { | ||
cache.set(config.args.one, config.args.one) | ||
.then(() => cache.has(config.args.one)) | ||
.then(result => res.send(result)); | ||
}); | ||
app.get('/length-itemcount', (req, res) => { | ||
const vals = []; | ||
cache.set(config.args.one, config.args.one) | ||
.then(() => cache.length()) | ||
.then((result) => { | ||
vals.push(result); | ||
return cache.itemCount(); | ||
}) | ||
.then((result) => { | ||
vals.push(result); | ||
return res.send(vals); | ||
}); | ||
}); | ||
app.get('/reset', (req, res) => { | ||
cache.reset() | ||
.then(() => cache.itemCount()) | ||
.then(result => res.send({ result })); | ||
}); | ||
app.get('/keys-values', (req, res) => { | ||
const vals = []; | ||
cache.set(config.args.one, config.args.one) | ||
.then(() => cache.keys()) | ||
.then((result) => { | ||
vals.push(result); | ||
return cache.values(); | ||
}) | ||
.then((result) => { | ||
vals.push(result); | ||
return res.send(vals); | ||
}) | ||
.catch(err => res.send(err)); | ||
}); | ||
app.get('/prune', (req, res) => { | ||
cache.set(config.args.one, config.args.one) | ||
.then(() => cache.prune()) | ||
.then(() => cache.itemCount()) | ||
.then(result => res.send({ result })); | ||
}); | ||
app.get('/dump', (req, res) => { | ||
cache.set(config.args.one, config.args.one) | ||
.then(() => cache.dump()) | ||
.then(result => res.send({ result })); | ||
}); | ||
app.get('/stale', (req, res) => { | ||
const vals = []; | ||
cache.stale() | ||
.then((stale) => { | ||
vals.push(stale); | ||
cache.stale(true) | ||
.then((stale2) => { | ||
vals.push(stale2); | ||
return res.send(vals); | ||
['tests', 'clusterTests'].forEach((test) => { | ||
Object.keys(testUtils[test]).forEach((method) => { | ||
app.get(`/${method}`, (req, res) => { | ||
testUtils[method]((err) => { | ||
if (err) { | ||
return res.send(err); | ||
} | ||
return res.send(true); | ||
}); | ||
}); | ||
@@ -238,28 +38,2 @@ }); | ||
app.get('/max', (req, res) => { | ||
const vals = []; | ||
cache.max() | ||
.then((max) => { | ||
vals.push(max); | ||
cache.max(10) | ||
.then((max2) => { | ||
vals.push(max2); | ||
return res.send(vals); | ||
}); | ||
}); | ||
}); | ||
app.get('/maxAge', (req, res) => { | ||
const vals = []; | ||
cache.maxAge() | ||
.then((maxAge) => { | ||
vals.push(maxAge); | ||
cache.maxAge(100) | ||
.then((maxAge2) => { | ||
vals.push(maxAge2); | ||
return res.send(vals); | ||
}); | ||
}); | ||
}); | ||
const server = http.createServer(app); | ||
@@ -266,0 +40,0 @@ server.listen(config.server.port, config.server.host); |
@@ -1,4 +0,3 @@ | ||
const should = require('should'); | ||
const LRUCache = require('../'); | ||
const config = require('./lib/config'); | ||
const TestUtils = require('./lib/test-utils'); | ||
@@ -11,205 +10,21 @@ describe('LRU Cache as Promised', () => { | ||
const testUtils = new TestUtils(cache); | ||
afterEach((done) => { | ||
cache.reset() | ||
.then(() => done()); | ||
testUtils.reset(() => done()); | ||
}); | ||
it('should set(key, value)', (done) => { | ||
cache.set(config.args.one, config.args.one) | ||
.then(() => done()) | ||
.catch(err => done(err)); | ||
}); | ||
it('should get(key)', (done) => { | ||
cache.set(config.args.one, config.args.one) | ||
.then(() => cache.get(config.args.one)) | ||
.then((result) => { | ||
should(result).equal(config.args.one); | ||
return done(); | ||
['tests'].forEach((test) => { | ||
Object.keys(testUtils[test]).forEach((method) => { | ||
it(`should ${testUtils[test][method]}`, (done) => { | ||
// run the request | ||
testUtils[method]((err) => { | ||
if (err) { | ||
return done(err); | ||
} | ||
return done(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
it('should del(key)', (done) => { | ||
cache.del(config.args.one) | ||
.then(() => cache.get(config.args.one)) | ||
.then((result) => { | ||
should(result).equal(undefined); | ||
return done(); | ||
}) | ||
.catch(err => done(err)); | ||
}); | ||
it('should incr(key)', (done) => { | ||
cache.incr(config.args.one) | ||
.then((value) => { | ||
should(value).eql(1); | ||
return cache.incr(config.args.one); | ||
}) | ||
.then((value) => { | ||
should(value).eql(2); | ||
return done(); | ||
}) | ||
.catch(err => done(err)); | ||
}); | ||
it('should incr(key, 2)', (done) => { | ||
const amount = 2; | ||
cache.incr(config.args.one, amount) | ||
.then((value) => { | ||
should(value).eql(2); | ||
return cache.incr(config.args.one, amount); | ||
}) | ||
.then((value) => { | ||
should(value).eql(4); | ||
return done(); | ||
}) | ||
.catch(err => done(err)); | ||
}); | ||
it('should decr(key)', (done) => { | ||
cache.decr(config.args.one) | ||
.then((value) => { | ||
should(value).eql(-1); | ||
return cache.decr(config.args.one); | ||
}) | ||
.then((value) => { | ||
should(value).eql(-2); | ||
return done(); | ||
}) | ||
.catch(err => done(err)); | ||
}); | ||
it('should decr(key, 2)', (done) => { | ||
const amount = 2; | ||
cache.decr(config.args.one, amount) | ||
.then((value) => { | ||
should(value).eql(-2); | ||
return cache.decr(config.args.one, amount); | ||
}) | ||
.then((value) => { | ||
should(value).eql(-4); | ||
return done(); | ||
}) | ||
.catch(err => done(err)); | ||
}); | ||
it('should add four keys and have the first fall out', (done) => { | ||
cache.set(config.args.one, config.args.one) | ||
.then(() => cache.set(config.args.two, config.args.two)) | ||
.then(() => cache.set(config.args.three, config.args.three)) | ||
.then(() => cache.set(config.args.four, config.args.four)) | ||
.then(() => cache.get(config.args.one)) | ||
.then((result) => { | ||
should(result).equal(undefined); | ||
return done(); | ||
}) | ||
.catch(err => done(err)); | ||
}); | ||
it('should add four keys and then access the first so the second falls out', (done) => { | ||
cache.set(config.args.one, config.args.one) | ||
.then(() => cache.set(config.args.two, config.args.two)) | ||
.then(() => cache.set(config.args.three, config.args.three)) | ||
.then(() => cache.get(config.args.one)) | ||
.then(() => cache.set(config.args.four, config.args.four)) | ||
.then(() => cache.get(config.args.one)) | ||
.then((result) => { | ||
should(result).equal(config.args.one); | ||
return done(); | ||
}) | ||
.catch(err => done(err)); | ||
}); | ||
it('should peek(key)', (done) => { | ||
const vals = []; | ||
cache.set(config.args.one, config.args.one) | ||
.then(() => cache.set(config.args.two, config.args.two)) | ||
.then(() => cache.set(config.args.three, config.args.three)) | ||
.then(() => cache.peek(config.args.one)) | ||
.then((result) => { | ||
vals.push(result); | ||
return cache.set(config.args.four, config.args.four); | ||
}) | ||
.then(() => cache.get(config.args.one)) | ||
.then((result) => { | ||
vals.push(result); | ||
should(vals).deepEqual(['one', undefined]); | ||
return done(); | ||
}) | ||
.catch(err => done(err)); | ||
}); | ||
it('should has(key)', (done) => { | ||
cache.set(config.args.one, config.args.one) | ||
.then(() => cache.has(config.args.one)) | ||
.then((result) => { | ||
should(result).equal(true); | ||
return done(); | ||
}) | ||
.catch(err => done(err)); | ||
}); | ||
it('should return length/itemCount', (done) => { | ||
const vals = []; | ||
cache.set(config.args.one, config.args.one) | ||
.then(() => cache.length()) | ||
.then((result) => { | ||
vals.push(result); | ||
return cache.itemCount(); | ||
}) | ||
.then((result) => { | ||
vals.push(result); | ||
should(vals).deepEqual([1, 1]); | ||
return done(); | ||
}) | ||
.catch(err => done(err)); | ||
}); | ||
it('should reset the cache', (done) => { | ||
cache.set(config.args.one, config.args.one) | ||
.then(() => cache.reset()) | ||
.then(() => cache.get(config.args.one)) | ||
.then((result) => { | ||
should(result).equal(undefined); | ||
return done(); | ||
}) | ||
.catch(err => done(err)); | ||
}); | ||
it('should get the itemCount', (done) => { | ||
cache.set(config.args.one, config.args.one) | ||
.then(() => cache.itemCount()) | ||
.then((result) => { | ||
should(result).equal(1); | ||
return done(); | ||
}) | ||
.catch(err => done(err)); | ||
}); | ||
it('should set the max()', (done) => { | ||
cache.max(10) | ||
.then((max) => { | ||
should(max).equal(10); | ||
return done(); | ||
}) | ||
.catch(err => done(err)); | ||
}); | ||
it('should set the stale()', (done) => { | ||
cache.stale(true) | ||
.then((stale) => { | ||
should(stale).equal(true); | ||
return done(); | ||
}) | ||
.catch(err => done(err)); | ||
}); | ||
it('should set the maxAge()', (done) => { | ||
cache.maxAge(10) | ||
.then((maxAge) => { | ||
should(maxAge).equal(10); | ||
return done(); | ||
}) | ||
.catch(err => done(err)); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16
34598
784
2