refactor(redis): require protocol in connection string
Signed-off-by: Phil Kuang <pkuang@factset.com>
This commit is contained in:
Vendored
+1
-1
@@ -137,7 +137,7 @@ export interface Config {
|
||||
| {
|
||||
store: 'redis';
|
||||
/**
|
||||
* A redis connection string in the form `user:pass@host:port`.
|
||||
* A redis connection string in the form `redis://user:pass@host:port`.
|
||||
* @secret
|
||||
*/
|
||||
connection: string;
|
||||
|
||||
+3
-4
@@ -195,14 +195,13 @@ describe('CacheManager', () => {
|
||||
});
|
||||
|
||||
it('returns a Redis client when configured', () => {
|
||||
const redisHostAndPort = '127.0.0.1:6379';
|
||||
const expectedHost = `redis://${redisHostAndPort}`;
|
||||
const redisConnection = 'redis://127.0.0.1:6379';
|
||||
const manager = CacheManager.fromConfig(
|
||||
new ConfigReader({
|
||||
backend: {
|
||||
cache: {
|
||||
store: 'redis',
|
||||
connection: redisHostAndPort,
|
||||
connection: redisConnection,
|
||||
},
|
||||
},
|
||||
}),
|
||||
@@ -218,7 +217,7 @@ describe('CacheManager', () => {
|
||||
expect(mockCacheCalls[0][0].store).toBeInstanceOf(KeyvRedis);
|
||||
const redis = KeyvRedis as jest.Mock;
|
||||
const mockRedisCalls = redis.mock.calls.splice(-1);
|
||||
expect(mockRedisCalls[0][0]).toEqual(expectedHost);
|
||||
expect(mockRedisCalls[0][0]).toEqual(redisConnection);
|
||||
});
|
||||
|
||||
describe('connection errors', () => {
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ export class CacheManager {
|
||||
return new Keyv({
|
||||
namespace: pluginId,
|
||||
ttl: defaultTtl,
|
||||
store: new KeyvRedis(`redis://${this.connection}`),
|
||||
store: new KeyvRedis(this.connection),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user