From ffd2abd4f7ac76a07fed2cdd520b4a318623af8c Mon Sep 17 00:00:00 2001 From: Luke Melia Date: Fri, 22 Oct 2021 16:31:54 -0400 Subject: [PATCH] Fix issue where ioredis constructor args were being passed in an unsupported manner --- lib/redis.js | 9 +++++++-- tests/unit/index-test.js | 24 ++++++++++++++---------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/lib/redis.js b/lib/redis.js index 11a4219..9a41185 100644 --- a/lib/redis.js +++ b/lib/redis.js @@ -31,8 +31,13 @@ module.exports = CoreObject.extend({ RedisLib = require('ioredis'); } - this._client = new RedisLib(libOptions); - + if (libOptions.url) { + let url = libOptions.url; + delete libOptions.url; + this._client = new RedisLib(url, libOptions); + } else { + this._client = new RedisLib(libOptions); + } this._maxRecentUploads = options.maxRecentUploads || 10; this._allowOverwrite = options.allowOverwrite || false; this._activationSuffix = options.activationSuffix || 'current'; diff --git a/tests/unit/index-test.js b/tests/unit/index-test.js index 17d8656..64e1b27 100644 --- a/tests/unit/index-test.js +++ b/tests/unit/index-test.js @@ -94,13 +94,16 @@ describe("redis plugin", function() { plugin.configure(context); plugin.readConfig("redisDeployClient"); - assert.isTrue( - redisLibStub.calledWith({ - host: "somehost", - port: 1234, - db: 4, - tls: { rejectUnauthorized: false } - }) + assert.deepEqual( + redisLibStub.lastCall.args, + [ + { + host: "somehost", + port: 1234, + db: 4, + tls: { rejectUnauthorized: false } + } + ] ); }); @@ -126,8 +129,9 @@ describe("redis plugin", function() { plugin.configure(context); plugin.readConfig("redisDeployClient"); - assert.isTrue( - redisLibStub.calledWith({ url: "redis://:password@host.amazonaws.com:6379/4" }) + assert.deepEqual( + redisLibStub.lastCall.args, + ["redis://:password@host.amazonaws.com:6379/4", {}], ); }); @@ -153,7 +157,7 @@ describe("redis plugin", function() { plugin.readConfig("redisDeployClient"); assert.isTrue( - redisLibStub.calledWith({ url: "redis://:password@host.amazonaws.com:6379/4" }) + redisLibStub.calledWith("redis://:password@host.amazonaws.com:6379/4") ); });