1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +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:
Shaya Potter
2024-10-15 17:46:52 +03:00
committed by GitHub
parent 2fc79bdfb3
commit b2d35c5286
1174 changed files with 45931 additions and 36274 deletions

View File

@@ -1,42 +1,49 @@
import { strict as assert } from 'assert';
import { strict as assert } from 'node:assert';
import testUtils, { GLOBAL } from '../test-utils';
import { RedisCommandArguments } from '.';
import { GeoReplyWith } from './generic-transformers';
import { transformArguments } from './GEOSEARCH_WITH';
import GEOSEARCH_WITH, { GEO_REPLY_WITH } from './GEOSEARCH_WITH';
import { CommandArguments } from '../RESP/types';
describe('GEOSEARCH WITH', () => {
testUtils.isVersionGreaterThanHook([6, 2]);
testUtils.isVersionGreaterThanHook([6, 2]);
it('transformArguments', () => {
const expectedReply: RedisCommandArguments = ['GEOSEARCH', 'key', 'FROMMEMBER', 'member', 'BYRADIUS', '1', 'm', 'WITHDIST'];
expectedReply.preserve = ['WITHDIST'];
it('transformArguments', () => {
const expectedReply: CommandArguments = ['GEOSEARCH', 'key', 'FROMMEMBER', 'member', 'BYRADIUS', '1', 'm', 'WITHDIST'];
expectedReply.preserve = ['WITHDIST'];
assert.deepEqual(
transformArguments('key', 'member', {
radius: 1,
unit: 'm'
}, [GeoReplyWith.DISTANCE]),
expectedReply
);
});
assert.deepEqual(
GEOSEARCH_WITH.transformArguments('key', 'member', {
radius: 1,
unit: 'm'
}, [GEO_REPLY_WITH.DISTANCE]),
expectedReply
);
});
testUtils.testWithClient('client.geoSearchWith', async client => {
assert.deepEqual(
await client.geoSearchWith('key', 'member', {
radius: 1,
unit: 'm'
}, [GeoReplyWith.DISTANCE]),
[]
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testAll('.geoSearchWith', async client => {
const [ , reply ] = await Promise.all([
client.geoAdd('key', {
member: 'member',
longitude: 1,
latitude: 2
}),
client.geoSearchWith('key', 'member', {
radius: 1,
unit: 'm'
}, [
GEO_REPLY_WITH.HASH,
GEO_REPLY_WITH.DISTANCE,
GEO_REPLY_WITH.COORDINATES
])
]);
testUtils.testWithCluster('cluster.geoSearchWith', async cluster => {
assert.deepEqual(
await cluster.geoSearchWith('key', 'member', {
radius: 1,
unit: 'm'
}, [GeoReplyWith.DISTANCE]),
[]
);
}, GLOBAL.CLUSTERS.OPEN);
assert.equal(reply.length, 1);
assert.equal(reply[0].member, 'member');
assert.equal(typeof reply[0].distance, 'string');
assert.equal(typeof reply[0].hash, 'number');
assert.equal(typeof reply[0].coordinates!.longitude, 'string');
assert.equal(typeof reply[0].coordinates!.latitude, 'string');
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});