You've already forked node-redis
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:
@@ -1,37 +1,48 @@
|
||||
import { strict as assert } from 'assert';
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import { transformArguments } from './ARRINDEX';
|
||||
import ARRINDEX from './ARRINDEX';
|
||||
|
||||
describe('ARRINDEX', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('simple', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', '$', 'json'),
|
||||
['JSON.ARRINDEX', 'key', '$', '"json"']
|
||||
);
|
||||
});
|
||||
|
||||
it('with start', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', '$', 'json', 1),
|
||||
['JSON.ARRINDEX', 'key', '$', '"json"', '1']
|
||||
);
|
||||
});
|
||||
|
||||
it('with start, end', () => {
|
||||
assert.deepEqual(
|
||||
transformArguments('key', '$', 'json', 1, 2),
|
||||
['JSON.ARRINDEX', 'key', '$', '"json"', '1', '2']
|
||||
);
|
||||
});
|
||||
describe('JSON.ARRINDEX', () => {
|
||||
describe('transformArguments', () => {
|
||||
it('simple', () => {
|
||||
assert.deepEqual(
|
||||
ARRINDEX.transformArguments('key', '$', 'value'),
|
||||
['JSON.ARRINDEX', 'key', '$', '"value"']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.json.arrIndex', async client => {
|
||||
await client.json.set('key', '$', []);
|
||||
|
||||
describe('with range', () => {
|
||||
it('start only', () => {
|
||||
assert.deepEqual(
|
||||
await client.json.arrIndex('key', '$', 'json'),
|
||||
[-1]
|
||||
ARRINDEX.transformArguments('key', '$', 'value', {
|
||||
range: {
|
||||
start: 0
|
||||
}
|
||||
}),
|
||||
['JSON.ARRINDEX', 'key', '$', '"value"', '0']
|
||||
);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
||||
it('with start and stop', () => {
|
||||
assert.deepEqual(
|
||||
ARRINDEX.transformArguments('key', '$', 'value', {
|
||||
range: {
|
||||
start: 0,
|
||||
stop: 1
|
||||
}
|
||||
}),
|
||||
['JSON.ARRINDEX', 'key', '$', '"value"', '0', '1']
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testWithClient('client.json.arrIndex', async client => {
|
||||
const [, reply] = await Promise.all([
|
||||
client.json.set('key', '$', []),
|
||||
client.json.arrIndex('key', '$', 'value')
|
||||
]);
|
||||
|
||||
assert.deepEqual(reply, [-1]);
|
||||
}, GLOBAL.SERVERS.OPEN);
|
||||
});
|
||||
|
Reference in New Issue
Block a user