1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +03:00

Merge branch 'master' of github.com:redis/node-redis into v5

This commit is contained in:
Leibale
2023-04-26 17:50:23 -04:00
2 changed files with 40 additions and 10 deletions

View File

@@ -607,11 +607,41 @@ describe('Client', () => {
} }
}); });
testUtils.testWithClient('executeIsolated', async client => { describe('isolationPool', () => {
const id = await client.clientId(), testUtils.testWithClient('executeIsolated', async client => {
isolatedId = await client.executeIsolated(isolatedClient => isolatedClient.clientId()); const id = await client.clientId(),
assert.ok(id !== isolatedId); isolatedId = await client.executeIsolated(isolatedClient => isolatedClient.clientId());
}, GLOBAL.SERVERS.OPEN); assert.ok(id !== isolatedId);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('should be able to use pool even before connect', async client => {
await client.executeIsolated(() => Promise.resolve());
// make sure to destroy isolation pool
await client.connect();
await client.disconnect();
}, {
...GLOBAL.SERVERS.OPEN,
disableClientSetup: true
});
testUtils.testWithClient('should work after reconnect (#2406)', async client => {
await client.disconnect();
await client.connect();
await client.executeIsolated(() => Promise.resolve());
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('should throw ClientClosedError after disconnect', async client => {
await client.connect();
await client.disconnect();
await assert.rejects(
client.executeIsolated(() => Promise.resolve()),
ClientClosedError
);
}, {
...GLOBAL.SERVERS.OPEN,
disableClientSetup: true
});
});
async function killClient< async function killClient<
M extends RedisModules, M extends RedisModules,
@@ -731,7 +761,7 @@ describe('Client', () => {
members.map<MemberTuple>(member => [member.value, member.score]).sort(sort) members.map<MemberTuple>(member => [member.value, member.score]).sort(sort)
); );
}, GLOBAL.SERVERS.OPEN); }, GLOBAL.SERVERS.OPEN);
describe('PubSub', () => { describe('PubSub', () => {
testUtils.testWithClient('should be able to publish and subscribe to messages', async publisher => { testUtils.testWithClient('should be able to publish and subscribe to messages', async publisher => {
function assertStringListener(message: string, channel: string) { function assertStringListener(message: string, channel: string) {

View File

@@ -128,7 +128,7 @@ export function transformTimestampArgument(timestamp: Timestamp): string {
} }
export function pushRetentionArgument(args: RedisCommandArguments, retention?: number): RedisCommandArguments { export function pushRetentionArgument(args: RedisCommandArguments, retention?: number): RedisCommandArguments {
if (retention) { if (retention !== undefined) {
args.push( args.push(
'RETENTION', 'RETENTION',
retention.toString() retention.toString()
@@ -144,7 +144,7 @@ export enum TimeSeriesEncoding {
} }
export function pushEncodingArgument(args: RedisCommandArguments, encoding?: TimeSeriesEncoding): RedisCommandArguments { export function pushEncodingArgument(args: RedisCommandArguments, encoding?: TimeSeriesEncoding): RedisCommandArguments {
if (encoding) { if (encoding !== undefined) {
args.push( args.push(
'ENCODING', 'ENCODING',
encoding encoding
@@ -155,7 +155,7 @@ export function pushEncodingArgument(args: RedisCommandArguments, encoding?: Tim
} }
export function pushChunkSizeArgument(args: RedisCommandArguments, chunkSize?: number): RedisCommandArguments { export function pushChunkSizeArgument(args: RedisCommandArguments, chunkSize?: number): RedisCommandArguments {
if (chunkSize) { if (chunkSize !== undefined) {
args.push( args.push(
'CHUNK_SIZE', 'CHUNK_SIZE',
chunkSize.toString() chunkSize.toString()
@@ -166,7 +166,7 @@ export function pushChunkSizeArgument(args: RedisCommandArguments, chunkSize?: n
} }
export function pushDuplicatePolicy(args: RedisCommandArguments, duplicatePolicy?: TimeSeriesDuplicatePolicies): RedisCommandArguments { export function pushDuplicatePolicy(args: RedisCommandArguments, duplicatePolicy?: TimeSeriesDuplicatePolicies): RedisCommandArguments {
if (duplicatePolicy) { if (duplicatePolicy !== undefined) {
args.push( args.push(
'DUPLICATE_POLICY', 'DUPLICATE_POLICY',
duplicatePolicy duplicatePolicy