Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
sinon.test(function (done) {
const client = new RedisMock()
this.stub(noderedis, 'createClient').returns(client)
// const spy = this.spy(client, 'set')
let metadata = {
foo: 'bar',
baz: 123
}
cache = new Cache({
directory: { enabled: false, path: './cache', extension: 'json' },
redis: { enabled: true, host: '127.0.0.1', port: 6379 }
})
cache.set('key-string', 'data', { metadata }).then(() => {
cache.getMetadata('key-string').then(metadata => {
metadata.should.eql(metadata)
sinon.test(function (done) {
const client = new RedisMock()
this.stub(noderedis, 'createClient').returns(client)
const spy = this.spy(client, 'set')
let metadata = {
foo: 'bar',
baz: 123
}
cache = new Cache({
directory: { enabled: false, path: './cache', extension: 'json' },
redis: { enabled: true, host: '127.0.0.1', port: 6379 }
})
cache.set('key-string', 'data', { metadata }).then(() => {
spy.called.should.eql(true)
spy.firstCall.args[0].indexOf('key-string').should.be.above(-1)
spy.secondCall.args[0].should.eql('___key-string___')
sinon.test(function (done) {
const stream = new Stream.Readable()
stream.push('data')
stream.push(null)
const client = new RedisMock()
this.stub(client, 'exists').yields(null, 1)
const getRange = this.stub(client, 'getrange')
getRange
.withArgs(Buffer.from('key1'), 0, 16383)
.yields(null, Buffer.from('data'))
getRange
.withArgs(Buffer.from('key1'), 16384, 32767)
.yields(null, Buffer.from(''))
this.stub(noderedis, 'createClient').returns(client)
cache = new Cache({
directory: { enabled: false, path: './cache', extension: 'json' },
redis: { enabled: true, host: '127.0.0.1', port: 6379 }
})