Skip to content

Commit ffd2abd

Browse files
committed
Fix issue where ioredis constructor args were being passed in an unsupported manner
1 parent b3ea9e5 commit ffd2abd

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

lib/redis.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,13 @@ module.exports = CoreObject.extend({
3131
RedisLib = require('ioredis');
3232
}
3333

34-
this._client = new RedisLib(libOptions);
35-
34+
if (libOptions.url) {
35+
let url = libOptions.url;
36+
delete libOptions.url;
37+
this._client = new RedisLib(url, libOptions);
38+
} else {
39+
this._client = new RedisLib(libOptions);
40+
}
3641
this._maxRecentUploads = options.maxRecentUploads || 10;
3742
this._allowOverwrite = options.allowOverwrite || false;
3843
this._activationSuffix = options.activationSuffix || 'current';

tests/unit/index-test.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,16 @@ describe("redis plugin", function() {
9494
plugin.configure(context);
9595
plugin.readConfig("redisDeployClient");
9696

97-
assert.isTrue(
98-
redisLibStub.calledWith({
99-
host: "somehost",
100-
port: 1234,
101-
db: 4,
102-
tls: { rejectUnauthorized: false }
103-
})
97+
assert.deepEqual(
98+
redisLibStub.lastCall.args,
99+
[
100+
{
101+
host: "somehost",
102+
port: 1234,
103+
db: 4,
104+
tls: { rejectUnauthorized: false }
105+
}
106+
]
104107
);
105108
});
106109

@@ -126,8 +129,9 @@ describe("redis plugin", function() {
126129
plugin.configure(context);
127130
plugin.readConfig("redisDeployClient");
128131

129-
assert.isTrue(
130-
redisLibStub.calledWith({ url: "redis://:password@host.amazonaws.com:6379/4" })
132+
assert.deepEqual(
133+
redisLibStub.lastCall.args,
134+
["redis://:password@host.amazonaws.com:6379/4", {}],
131135
);
132136
});
133137

@@ -153,7 +157,7 @@ describe("redis plugin", function() {
153157
plugin.readConfig("redisDeployClient");
154158

155159
assert.isTrue(
156-
redisLibStub.calledWith({ url: "redis://:password@host.amazonaws.com:6379/4" })
160+
redisLibStub.calledWith("redis://:password@host.amazonaws.com:6379/4")
157161
);
158162
});
159163

0 commit comments

Comments
 (0)