You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
V5 bringing RESP3, Sentinel and TypeMapping to node-redis
RESP3 Support - Some commands responses in RESP3 aren't stable yet and therefore return an "untyped" ReplyUnion. Sentinel TypeMapping Correctly types Multi commands Note: some API changes to be further documented in v4-to-v5.md
This commit is contained in:
@@ -1,65 +1,75 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './ZRANGE_WITHSCORES';
|
||||
import ZRANGE_WITHSCORES from './ZRANGE_WITHSCORES';
|
||||
|
||||
describe('ZRANGE WITHSCORES', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('simple', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('src', 0, 1),
|
||||
['ZRANGE', 'src', '0', '1', 'WITHSCORES']
|
||||
);
|
||||
});
|
||||
|
||||
it('with BY', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('src', 0, 1, {
|
||||
BY: 'SCORE'
|
||||
}),
|
||||
['ZRANGE', 'src', '0', '1', 'BYSCORE', 'WITHSCORES']
|
||||
);
|
||||
});
|
||||
|
||||
it('with REV', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('src', 0, 1, {
|
||||
REV: true
|
||||
}),
|
||||
['ZRANGE', 'src', '0', '1', 'REV', 'WITHSCORES']
|
||||
);
|
||||
});
|
||||
|
||||
it('with LIMIT', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('src', 0, 1, {
|
||||
LIMIT: {
|
||||
offset: 0,
|
||||
count: 1
|
||||
}
|
||||
}),
|
||||
['ZRANGE', 'src', '0', '1', 'LIMIT', '0', '1', 'WITHSCORES']
|
||||
);
|
||||
});
|
||||
|
||||
it('with BY & REV & LIMIT', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('src', 0, 1, {
|
||||
BY: 'SCORE',
|
||||
REV: true,
|
||||
LIMIT: {
|
||||
offset: 0,
|
||||
count: 1
|
||||
}
|
||||
}),
|
||||
['ZRANGE', 'src', '0', '1', 'BYSCORE', 'REV', 'LIMIT', '0', '1', 'WITHSCORES']
|
||||
);
|
||||
});
|
||||
describe('transformArguments', () => {
|
||||
it('simple', () => {
|
||||
assert.deepEqual(
|
||||
ZRANGE_WITHSCORES.transformArguments('src', 0, 1),
|
||||
['ZRANGE', 'src', '0', '1', 'WITHSCORES']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.zRangeWithScores', async client => {
|
||||
assert.deepEqual(
|
||||
await client.zRangeWithScores('src', 0, 1),
|
||||
[]
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
it('with BY', () => {
|
||||
assert.deepEqual(
|
||||
ZRANGE_WITHSCORES.transformArguments('src', 0, 1, {
|
||||
BY: 'SCORE'
|
||||
}),
|
||||
['ZRANGE', 'src', '0', '1', 'BYSCORE', 'WITHSCORES']
|
||||
);
|
||||
});
|
||||
|
||||
it('with REV', () => {
|
||||
assert.deepEqual(
|
||||
ZRANGE_WITHSCORES.transformArguments('src', 0, 1, {
|
||||
REV: true
|
||||
}),
|
||||
['ZRANGE', 'src', '0', '1', 'REV', 'WITHSCORES']
|
||||
);
|
||||
});
|
||||
|
||||
it('with LIMIT', () => {
|
||||
assert.deepEqual(
|
||||
ZRANGE_WITHSCORES.transformArguments('src', 0, 1, {
|
||||
LIMIT: {
|
||||
offset: 0,
|
||||
count: 1
|
||||
}
|
||||
}),
|
||||
['ZRANGE', 'src', '0', '1', 'LIMIT', '0', '1', 'WITHSCORES']
|
||||
);
|
||||
});
|
||||
|
||||
it('with BY & REV & LIMIT', () => {
|
||||
assert.deepEqual(
|
||||
ZRANGE_WITHSCORES.transformArguments('src', 0, 1, {
|
||||
BY: 'SCORE',
|
||||
REV: true,
|
||||
LIMIT: {
|
||||
offset: 0,
|
||||
count: 1
|
||||
}
|
||||
}),
|
||||
['ZRANGE', 'src', '0', '1', 'BYSCORE', 'REV', 'LIMIT', '0', '1', 'WITHSCORES']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testAll('zRangeWithScores', async client => {
|
||||
const members = [{
|
||||
value: '1',
|
||||
score: 1
|
||||
}];
|
||||
|
||||
const [, reply] = await Promise.all([
|
||||
client.zAdd('key', members),
|
||||
client.zRangeWithScores('key', 0, 1)
|
||||
]);
|
||||
|
||||
assert.deepEqual(reply, members);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user