You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
feat: add support for vector sets (#2998)
* wip * improve the vadd api * resp3 tests * fix some tests * extract json helper functions in client package * use transformJsonReply * remove the CACHEABLE flag for all vector set commands currently, client side caching is not supported for vector set commands by the server * properly transform vinfo result * add resp3 test for vlinks * add more tests for vrandmember * fix vrem return types * fix vsetattr return type * fix vsim_withscores * implement vlinks_withscores * set minimum docker image version to 8 * align return types * add RAW variant for VEMB -> VEMB_RAW * use the new parseCommand api
This commit is contained in:
committed by
GitHub
parent
b52177752e
commit
c5b4f47975
58
packages/client/lib/commands/VSETATTR.spec.ts
Normal file
58
packages/client/lib/commands/VSETATTR.spec.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import VSETATTR from './VSETATTR';
|
||||
import { BasicCommandParser } from '../client/parser';
|
||||
|
||||
describe('VSETATTR', () => {
|
||||
describe('parseCommand', () => {
|
||||
it('with object', () => {
|
||||
const parser = new BasicCommandParser();
|
||||
VSETATTR.parseCommand(parser, 'key', 'element', { name: 'test', value: 42 }),
|
||||
assert.deepEqual(
|
||||
parser.redisArgs,
|
||||
['VSETATTR', 'key', 'element', '{"name":"test","value":42}']
|
||||
);
|
||||
});
|
||||
|
||||
it('with string', () => {
|
||||
const parser = new BasicCommandParser();
|
||||
VSETATTR.parseCommand(parser, 'key', 'element', '{"name":"test"}'),
|
||||
assert.deepEqual(
|
||||
parser.redisArgs,
|
||||
['VSETATTR', 'key', 'element', '{"name":"test"}']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testAll('vSetAttr', async client => {
|
||||
await client.vAdd('key', [1.0, 2.0, 3.0], 'element');
|
||||
|
||||
assert.equal(
|
||||
await client.vSetAttr('key', 'element', { name: 'test', value: 42 }),
|
||||
true
|
||||
);
|
||||
}, {
|
||||
client: { ...GLOBAL.SERVERS.OPEN, minimumDockerVersion: [8, 0] },
|
||||
cluster: { ...GLOBAL.CLUSTERS.OPEN, minimumDockerVersion: [8, 0] }
|
||||
});
|
||||
|
||||
testUtils.testWithClient('vSetAttr with RESP3 - returns boolean', async client => {
|
||||
await client.vAdd('resp3-key', [1.0, 2.0, 3.0], 'resp3-element');
|
||||
|
||||
const result = await client.vSetAttr('resp3-key', 'resp3-element', {
|
||||
name: 'test-item',
|
||||
category: 'electronics',
|
||||
price: 99.99
|
||||
});
|
||||
|
||||
// RESP3 returns boolean instead of number
|
||||
assert.equal(typeof result, 'boolean');
|
||||
assert.equal(result, true);
|
||||
}, {
|
||||
...GLOBAL.SERVERS.OPEN,
|
||||
clientOptions: {
|
||||
RESP: 3
|
||||
},
|
||||
minimumDockerVersion: [8, 0]
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user