From 645295948205ee0da051ae8d2fb17b808c4d8eda Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Wed, 11 Nov 2020 11:35:33 +0000 Subject: [PATCH] [misc] do not access potentially undefined opts --- libraries/redis-wrapper/index.js | 2 +- libraries/redis-wrapper/test/unit/src/test.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/redis-wrapper/index.js b/libraries/redis-wrapper/index.js index 45d0fc383c..211cb15eff 100644 --- a/libraries/redis-wrapper/index.js +++ b/libraries/redis-wrapper/index.js @@ -33,7 +33,7 @@ function createClient(opts) { } let client - if (opts.cluster) { + if (standardOpts.cluster) { delete standardOpts.cluster client = new Redis.Cluster(opts.cluster, standardOpts) } else { diff --git a/libraries/redis-wrapper/test/unit/src/test.js b/libraries/redis-wrapper/test/unit/src/test.js index 12671d539b..3e9f4fb4de 100644 --- a/libraries/redis-wrapper/test/unit/src/test.js +++ b/libraries/redis-wrapper/test/unit/src/test.js @@ -78,6 +78,10 @@ describe('index', function () { }) }) + it('should work without opts', function () { + this.redis.createClient() + }) + it('should use the ioredis driver in single-instance mode if a non array is passed', function () { const client = this.redis.createClient(this.standardOpts) return assert.equal(client.constructor, this.ioredis)