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,57 +1,54 @@
import { strict as assert } from 'assert';
import { strict as assert } from 'node:assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './GEODIST';
import GEODIST from './GEODIST';
describe('GEODIST', () => {
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
transformArguments('key', '1', '2'),
['GEODIST', 'key', '1', '2']
);
});
it('with unit', () => {
assert.deepEqual(
transformArguments('key', '1', '2', 'm'),
['GEODIST', 'key', '1', '2', 'm']
);
});
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
GEODIST.transformArguments('key', '1', '2'),
['GEODIST', 'key', '1', '2']
);
});
describe('client.geoDist', () => {
testUtils.testWithClient('null', async client => {
assert.equal(
await client.geoDist('key', '1', '2'),
null
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('with value', async client => {
const [, dist] = await Promise.all([
client.geoAdd('key', [{
member: '1',
longitude: 1,
latitude: 1
}, {
member: '2',
longitude: 2,
latitude: 2
}]),
client.geoDist('key', '1', '2')
]);
assert.equal(
dist,
157270.0561
);
}, GLOBAL.SERVERS.OPEN);
it('with unit', () => {
assert.deepEqual(
GEODIST.transformArguments('key', '1', '2', 'm'),
['GEODIST', 'key', '1', '2', 'm']
);
});
});
testUtils.testWithCluster('cluster.geoDist', async cluster => {
assert.equal(
await cluster.geoDist('key', '1', '2'),
null
);
}, GLOBAL.CLUSTERS.OPEN);
testUtils.testAll('geoDist null', async client => {
assert.equal(
await client.geoDist('key', '1', '2'),
null
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
testUtils.testAll('geoDist with member', async client => {
const [, dist] = await Promise.all([
client.geoAdd('key', [{
member: '1',
longitude: 1,
latitude: 1
}, {
member: '2',
longitude: 2,
latitude: 2
}]),
client.geoDist('key', '1', '2')
]);
assert.equal(
dist,
157270.0561
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});