Skip to content

Commit 25939e5

Browse files
authored
Merge d2dbea6 into a217cc1
2 parents a217cc1 + d2dbea6 commit 25939e5

File tree

5 files changed

+130
-0
lines changed

5 files changed

+130
-0
lines changed

packages/client/lib/cluster/commands.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,13 @@ import * as ZRANGEBYSCORE_WITHSCORES from '../commands/ZRANGEBYSCORE_WITHSCORES'
200200
import * as ZRANGEBYSCORE from '../commands/ZRANGEBYSCORE';
201201
import * as ZRANGESTORE from '../commands/ZRANGESTORE';
202202
import * as ZRANK from '../commands/ZRANK';
203+
import * as ZRANK_WITHSCORE from '../commands/ZRANK_WITHSCORE';
203204
import * as ZREM from '../commands/ZREM';
204205
import * as ZREMRANGEBYLEX from '../commands/ZREMRANGEBYLEX';
205206
import * as ZREMRANGEBYRANK from '../commands/ZREMRANGEBYRANK';
206207
import * as ZREMRANGEBYSCORE from '../commands/ZREMRANGEBYSCORE';
207208
import * as ZREVRANK from '../commands/ZREVRANK';
209+
import * as ZREVRANK_WITHSCORE from '../commands/ZREVRANK_WITHSCORE';
208210
import * as ZSCAN from '../commands/ZSCAN';
209211
import * as ZSCORE from '../commands/ZSCORE';
210212
import * as ZUNION_WITHSCORES from '../commands/ZUNION_WITHSCORES';
@@ -614,6 +616,8 @@ export default {
614616
zRangeStore: ZRANGESTORE,
615617
ZRANK,
616618
zRank: ZRANK,
619+
ZRANK_WITHSCORE,
620+
zRankWithScore: ZRANK_WITHSCORE,
617621
ZREM,
618622
zRem: ZREM,
619623
ZREMRANGEBYLEX,
@@ -624,6 +628,8 @@ export default {
624628
zRemRangeByScore: ZREMRANGEBYSCORE,
625629
ZREVRANK,
626630
zRevRank: ZREVRANK,
631+
ZREVRANK_WITHSCORE,
632+
zRevRankWithScore: ZREVRANK_WITHSCORE,
627633
ZSCAN,
628634
zScan: ZSCAN,
629635
ZSCORE,
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { strict as assert } from 'assert';
2+
import testUtils, { GLOBAL } from '../test-utils';
3+
import { transformArguments, transformReply } from './ZRANK_WITHSCORE';
4+
5+
describe('ZRANK WITHSCORE', () => {
6+
testUtils.isVersionGreaterThanHook([7, 2]);
7+
8+
it('transformArguments', () => {
9+
assert.deepEqual(
10+
transformArguments('key', 'member'),
11+
['ZRANK', 'key', 'member', 'WITHSCORE']
12+
);
13+
});
14+
15+
it('transformReply', () => {
16+
assert.deepEqual(
17+
transformReply([]),
18+
null
19+
);
20+
assert.deepEqual(
21+
transformReply(['test', '1']),
22+
{
23+
value: 'test',
24+
score: 1
25+
}
26+
);
27+
});
28+
29+
testUtils.testWithClient('client.zRankWithScore empty response', async client => {
30+
assert.deepEqual(
31+
await client.zRankWithScore('key', 'member'),
32+
null
33+
);
34+
}, GLOBAL.SERVERS.OPEN);
35+
36+
testUtils.testWithClient('client.zRankWithScore', async client => {
37+
await Promise.all([
38+
client.zAdd('zRankWithScoreSet', 1, 'one'),
39+
client.zAdd('zRankWithScoreSet', 2, 'two')
40+
]);
41+
assert.deepEqual(
42+
await client.zRankWithScore('zRankWithScoreSet', 'one'),
43+
{
44+
value: 'one',
45+
score: 0
46+
}
47+
);
48+
}, GLOBAL.SERVERS.OPEN);
49+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { RedisCommandArguments } from '.';
2+
import { transformArguments as transformZRankArguments } from './ZRANK';
3+
4+
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './ZRANK';
5+
6+
export function transformArguments(...args: Parameters<typeof transformZRankArguments>): RedisCommandArguments {
7+
return [
8+
...transformZRankArguments(...args),
9+
'WITHSCORE'
10+
];
11+
}
12+
13+
export { transformSortedSetMemberNullReply as transformReply } from './generic-transformers';
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { strict as assert } from 'assert';
2+
import testUtils, { GLOBAL } from '../test-utils';
3+
import { transformArguments, transformReply } from './ZREVRANK_WITHSCORE';
4+
5+
describe('ZREVRANK WITHSCORE', () => {
6+
testUtils.isVersionGreaterThanHook([7, 2]);
7+
8+
it('transformArguments', () => {
9+
assert.deepEqual(
10+
transformArguments('key', 'member'),
11+
['ZREVRANK', 'key', 'member', 'WITHSCORE']
12+
);
13+
});
14+
15+
it('transformReply', () => {
16+
assert.deepEqual(
17+
transformReply([]),
18+
null
19+
);
20+
assert.deepEqual(
21+
transformReply(['test', '1']),
22+
{
23+
value: 'test',
24+
score: 1
25+
}
26+
);
27+
});
28+
29+
testUtils.testWithClient('client.zRevRankWithScore empty response', async client => {
30+
assert.deepEqual(
31+
await client.zRevRankWithScore('key', 'member'),
32+
null
33+
);
34+
}, GLOBAL.SERVERS.OPEN);
35+
36+
testUtils.testWithClient('client.zRevRankWithScore', async client => {
37+
await Promise.all([
38+
client.zAdd('zRevRankWithScoreSet', 1, 'one'),
39+
client.zAdd('zRevRankWithScoreSet', 2, 'two')
40+
]);
41+
assert.deepEqual(
42+
await client.zRevRankWithScore('zRevRankWithScoreSet', 'one'),
43+
{
44+
value: 'one',
45+
score: 1
46+
}
47+
);
48+
}, GLOBAL.SERVERS.OPEN);
49+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { RedisCommandArguments } from '.';
2+
import { transformArguments as transformZRevRankArguments } from './ZREVRANK';
3+
4+
export { FIRST_KEY_INDEX, IS_READ_ONLY } from './ZREVRANK';
5+
6+
export function transformArguments(...args: Parameters<typeof transformZRevRankArguments>): RedisCommandArguments {
7+
return [
8+
...transformZRevRankArguments(...args),
9+
'WITHSCORE'
10+
];
11+
}
12+
13+
export { transformSortedSetMemberNullReply as transformReply } from './generic-transformers';

0 commit comments

Comments
 (0)