1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-04 15:02:09 +03:00

more commands

This commit is contained in:
dovi
2023-07-06 15:51:12 -04:00
parent d986ff52b6
commit e64946566a
20 changed files with 295 additions and 261 deletions

View File

@@ -1,28 +1,28 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './DEBUG_MEMORY';
import DEBUG_MEMORY from './DEBUG_MEMORY';
describe('DEBUG MEMORY', () => {
describe('transformArguments', () => {
it('without path', () => {
assert.deepEqual(
transformArguments('key'),
['JSON.DEBUG', 'MEMORY', 'key']
);
});
it('with path', () => {
assert.deepEqual(
transformArguments('key', '$'),
['JSON.DEBUG', 'MEMORY', 'key', '$']
);
});
describe('transformArguments', () => {
it('without path', () => {
assert.deepEqual(
DEBUG_MEMORY.transformArguments('key'),
['JSON.DEBUG', 'MEMORY', 'key']
);
});
testUtils.testWithClient('client.json.arrTrim', async client => {
assert.deepEqual(
await client.json.debugMemory('key', '$'),
[]
);
}, GLOBAL.SERVERS.OPEN);
it('with path', () => {
assert.deepEqual(
DEBUG_MEMORY.transformArguments('key', '$'),
['JSON.DEBUG', 'MEMORY', 'key', '$']
);
});
});
testUtils.testWithClient('client.json.arrTrim', async client => {
assert.deepEqual(
await client.json.debugMemory('key', '$'),
[]
);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,13 +1,16 @@
export const FIRST_KEY_INDEX = 2;
import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
export function transformArguments(key: string, path?: string): Array<string> {
export default {
FIRST_KEY_INDEX: 2,
IS_READ_ONLY: false,
transformArguments(key: RedisArgument, path?: RedisArgument) {
const args = ['JSON.DEBUG', 'MEMORY', key];
if (path) {
args.push(path);
args.push(path);
}
return args;
}
export declare function transformReply(): number;
},
transformReply: undefined as unknown as () => NumberReply
} as const satisfies Command;

View File

@@ -1,28 +1,29 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './DEL';
import DEL from './DEL';
describe('DEL', () => {
describe('transformArguments', () => {
it('key', () => {
assert.deepEqual(
transformArguments('key'),
['JSON.DEL', 'key']
);
});
it('key, path', () => {
assert.deepEqual(
transformArguments('key', '$.path'),
['JSON.DEL', 'key', '$.path']
);
});
describe('transformArguments', () => {
it('key', () => {
assert.deepEqual(
DEL.transformArguments('key'),
['JSON.DEL', 'key']
);
});
testUtils.testWithClient('client.json.del', async client => {
assert.deepEqual(
await client.json.del('key'),
0
);
}, GLOBAL.SERVERS.OPEN);
it('key, path', () => {
assert.deepEqual(
DEL.transformArguments('key', '$.path'),
['JSON.DEL', 'key', '$.path']
);
});
});
testUtils.testWithClient('client.json.del', async client => {
assert.deepEqual(
await client.json.del('key'),
0
);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,13 +1,16 @@
export const FIRST_KEY_INDEX = 1;
import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
export function transformArguments(key: string, path?: string): Array<string> {
export default {
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: false,
transformArguments(key: RedisArgument, path?: RedisArgument) {
const args = ['JSON.DEL', key];
if (path) {
args.push(path);
args.push(path);
}
return args;
}
export declare function transformReply(): number;
},
transformReply: undefined as unknown as () => NumberReply
} as const satisfies Command;

View File

@@ -1,28 +1,28 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './FORGET';
import FORGET from './FORGET';
describe('FORGET', () => {
describe('transformArguments', () => {
it('key', () => {
assert.deepEqual(
transformArguments('key'),
['JSON.FORGET', 'key']
);
});
it('key, path', () => {
assert.deepEqual(
transformArguments('key', '$.path'),
['JSON.FORGET', 'key', '$.path']
);
});
describe('transformArguments', () => {
it('key', () => {
assert.deepEqual(
FORGET.transformArguments('key'),
['JSON.FORGET', 'key']
);
});
testUtils.testWithClient('client.json.forget', async client => {
assert.deepEqual(
await client.json.forget('key'),
0
);
}, GLOBAL.SERVERS.OPEN);
it('key, path', () => {
assert.deepEqual(
FORGET.transformArguments('key', '$.path'),
['JSON.FORGET', 'key', '$.path']
);
});
});
testUtils.testWithClient('client.json.forget', async client => {
assert.deepEqual(
await client.json.forget('key'),
0
);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,13 +1,16 @@
export const FIRST_KEY_INDEX = 1;
import { RedisArgument, NumberReply, Command } from '@redis/client/dist/lib/RESP/types';
export function transformArguments(key: string, path?: string): Array<string> {
export default {
FIRST_KEY_INDEX: 1,
IS_READ_ONLY: false,
transformArguments(key: RedisArgument, path?: RedisArgument) {
const args = ['JSON.FORGET', key];
if (path) {
args.push(path);
args.push(path);
}
return args;
}
export declare function transformReply(): number;
},
transformReply: undefined as unknown as () => NumberReply
} as const satisfies Command;