You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-09 00:22:08 +03:00
fix INCRBY
This commit is contained in:
@@ -1,19 +1,19 @@
|
|||||||
import { strict as assert } from 'assert';
|
import { strict as assert } from 'assert';
|
||||||
import testUtils, { GLOBAL } from '../test-utils';
|
import testUtils, { GLOBAL } from '../test-utils';
|
||||||
import { transformArguments } from './INCRBY';
|
import INCRBY from './INCRBY';
|
||||||
|
|
||||||
describe('INCRBY', () => {
|
describe('INCRBY', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('without options', () => {
|
it('without options', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', 1),
|
INCRBY.transformArguments('key', 1),
|
||||||
['TS.INCRBY', 'key', '1']
|
['TS.INCRBY', 'key', '1']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with TIMESTAMP', () => {
|
it('with TIMESTAMP', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', 1, {
|
INCRBY.transformArguments('key', 1, {
|
||||||
TIMESTAMP: '*'
|
TIMESTAMP: '*'
|
||||||
}),
|
}),
|
||||||
['TS.INCRBY', 'key', '1', 'TIMESTAMP', '*']
|
['TS.INCRBY', 'key', '1', 'TIMESTAMP', '*']
|
||||||
@@ -22,7 +22,7 @@ describe('INCRBY', () => {
|
|||||||
|
|
||||||
it('with RETENTION', () => {
|
it('with RETENTION', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', 1, {
|
INCRBY.transformArguments('key', 1, {
|
||||||
RETENTION: 1
|
RETENTION: 1
|
||||||
}),
|
}),
|
||||||
['TS.INCRBY', 'key', '1', 'RETENTION', '1']
|
['TS.INCRBY', 'key', '1', 'RETENTION', '1']
|
||||||
@@ -31,7 +31,7 @@ describe('INCRBY', () => {
|
|||||||
|
|
||||||
it('with UNCOMPRESSED', () => {
|
it('with UNCOMPRESSED', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', 1, {
|
INCRBY.transformArguments('key', 1, {
|
||||||
UNCOMPRESSED: true
|
UNCOMPRESSED: true
|
||||||
}),
|
}),
|
||||||
['TS.INCRBY', 'key', '1', 'UNCOMPRESSED']
|
['TS.INCRBY', 'key', '1', 'UNCOMPRESSED']
|
||||||
@@ -40,7 +40,7 @@ describe('INCRBY', () => {
|
|||||||
|
|
||||||
it('without UNCOMPRESSED', () => {
|
it('without UNCOMPRESSED', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', 1, {
|
INCRBY.transformArguments('key', 1, {
|
||||||
UNCOMPRESSED: false
|
UNCOMPRESSED: false
|
||||||
}),
|
}),
|
||||||
['TS.INCRBY', 'key', '1']
|
['TS.INCRBY', 'key', '1']
|
||||||
@@ -49,7 +49,7 @@ describe('INCRBY', () => {
|
|||||||
|
|
||||||
it('with CHUNK_SIZE', () => {
|
it('with CHUNK_SIZE', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', 1, {
|
INCRBY.transformArguments('key', 1, {
|
||||||
CHUNK_SIZE: 1
|
CHUNK_SIZE: 1
|
||||||
}),
|
}),
|
||||||
['TS.INCRBY', 'key', '1', 'CHUNK_SIZE', '1']
|
['TS.INCRBY', 'key', '1', 'CHUNK_SIZE', '1']
|
||||||
@@ -58,7 +58,7 @@ describe('INCRBY', () => {
|
|||||||
|
|
||||||
it('with LABELS', () => {
|
it('with LABELS', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', 1, {
|
INCRBY.transformArguments('key', 1, {
|
||||||
LABELS: { label: 'value' }
|
LABELS: { label: 'value' }
|
||||||
}),
|
}),
|
||||||
['TS.INCRBY', 'key', '1', 'LABELS', 'label', 'value']
|
['TS.INCRBY', 'key', '1', 'LABELS', 'label', 'value']
|
||||||
@@ -67,7 +67,7 @@ describe('INCRBY', () => {
|
|||||||
|
|
||||||
it('with TIMESTAMP, RETENTION, UNCOMPRESSED, CHUNK_SIZE and LABELS', () => {
|
it('with TIMESTAMP, RETENTION, UNCOMPRESSED, CHUNK_SIZE and LABELS', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', 1, {
|
INCRBY.transformArguments('key', 1, {
|
||||||
TIMESTAMP: '*',
|
TIMESTAMP: '*',
|
||||||
RETENTION: 1,
|
RETENTION: 1,
|
||||||
UNCOMPRESSED: true,
|
UNCOMPRESSED: true,
|
||||||
|
@@ -1,10 +1,11 @@
|
|||||||
import { RedisCommandArguments } from '@redis/client/dist/lib/commands';
|
|
||||||
import { IncrDecrOptions, transformIncrDecrArguments } from '.';
|
import { IncrDecrOptions, transformIncrDecrArguments } from '.';
|
||||||
|
import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
|
||||||
|
|
||||||
export const FIRST_KEY_INDEX = 1;
|
export default {
|
||||||
|
FIRST_KEY_INDEX: 1,
|
||||||
export function transformArguments(key: string, value: number, options?: IncrDecrOptions): RedisCommandArguments {
|
IS_READ_ONLY: false,
|
||||||
|
transformArguments(key: RedisArgument, value: number, options?: IncrDecrOptions) {
|
||||||
return transformIncrDecrArguments('TS.INCRBY', key, value, options);
|
return transformIncrDecrArguments('TS.INCRBY', key, value, options);
|
||||||
}
|
},
|
||||||
|
transformReply: undefined as unknown as () => NumberReply
|
||||||
export declare function transformReply(): number;
|
} as const satisfies Command;
|
||||||
|
Reference in New Issue
Block a user