1
0
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:
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,66 @@
import { strict as assert } from 'assert';
import { strict as assert } from 'node:assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ARRPOP';
import ARRPOP from './ARRPOP';
describe('ARRPOP', () => {
describe('transformArguments', () => {
it('key', () => {
assert.deepEqual(
transformArguments('key'),
['JSON.ARRPOP', 'key']
);
});
it('key, path', () => {
assert.deepEqual(
transformArguments('key', '$'),
['JSON.ARRPOP', 'key', '$']
);
});
it('key, path, index', () => {
assert.deepEqual(
transformArguments('key', '$', 0),
['JSON.ARRPOP', 'key', '$', '0']
);
});
describe('JSON.ARRPOP', () => {
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
ARRPOP.transformArguments('key'),
['JSON.ARRPOP', 'key']
);
});
describe('client.json.arrPop', () => {
testUtils.testWithClient('null', async client => {
await client.json.set('key', '.', []);
assert.equal(
await client.json.arrPop('key', '.'),
null
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('with value', async client => {
await client.json.set('key', '.', ['value']);
assert.equal(
await client.json.arrPop('key', '.'),
'value'
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('array', async client => {
await client.json.set('key', '$', ['value']);
assert.deepEqual(
await client.json.arrPop('key', '$'),
['value']
);
}, GLOBAL.SERVERS.OPEN);
it('with path', () => {
assert.deepEqual(
ARRPOP.transformArguments('key', {
path: '$'
}),
['JSON.ARRPOP', 'key', '$']
);
});
it('with path and index', () => {
assert.deepEqual(
ARRPOP.transformArguments('key', {
path: '$',
index: 0
}),
['JSON.ARRPOP', 'key', '$', '0']
);
});
});
describe('client.json.arrPop', () => {
testUtils.testWithClient('without path and value', async client => {
const [, reply] = await Promise.all([
client.json.set('key', '$', []),
client.json.arrPop('key')
]);
assert.equal(reply, null);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('. path with value', async client => {
const [, reply] = await Promise.all([
client.json.set('key', '.', ['value']),
client.json.arrPop('key', {
path: '.'
})
]);
assert.equal(reply, 'value');
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('$ path with value', async client => {
const [, reply] = await Promise.all([
client.json.set('key', '$', ['value']),
client.json.arrPop('key', {
path: '$'
})
]);
assert.deepEqual(reply, ['value']);
}, GLOBAL.SERVERS.OPEN);
});
});