You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-04 15:02:09 +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
60
packages/client/lib/commands/VCARD.spec.ts
Normal file
60
packages/client/lib/commands/VCARD.spec.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import VCARD from './VCARD';
|
||||
import { BasicCommandParser } from '../client/parser';
|
||||
|
||||
describe('VCARD', () => {
|
||||
it('parseCommand', () => {
|
||||
const parser = new BasicCommandParser();
|
||||
VCARD.parseCommand(parser, 'key')
|
||||
assert.deepEqual(
|
||||
parser.redisArgs,
|
||||
['VCARD', 'key']
|
||||
);
|
||||
});
|
||||
|
||||
testUtils.testAll('vCard', async client => {
|
||||
await client.vAdd('key', [1.0, 2.0, 3.0], 'element1');
|
||||
await client.vAdd('key', [4.0, 5.0, 6.0], 'element2');
|
||||
|
||||
assert.equal(
|
||||
await client.vCard('key'),
|
||||
2
|
||||
);
|
||||
|
||||
assert.equal(await client.vCard('unknown'), 0);
|
||||
}, {
|
||||
client: { ...GLOBAL.SERVERS.OPEN, minimumDockerVersion: [8, 0] },
|
||||
cluster: { ...GLOBAL.CLUSTERS.OPEN, minimumDockerVersion: [8, 0] }
|
||||
});
|
||||
|
||||
testUtils.testWithClient('vCard with RESP3', async client => {
|
||||
// Test empty vector set
|
||||
assert.equal(
|
||||
await client.vCard('resp3-empty-key'),
|
||||
0
|
||||
);
|
||||
|
||||
// Add elements and test cardinality
|
||||
await client.vAdd('resp3-key', [1.0, 2.0], 'elem1');
|
||||
assert.equal(
|
||||
await client.vCard('resp3-key'),
|
||||
1
|
||||
);
|
||||
|
||||
await client.vAdd('resp3-key', [3.0, 4.0], 'elem2');
|
||||
await client.vAdd('resp3-key', [5.0, 6.0], 'elem3');
|
||||
assert.equal(
|
||||
await client.vCard('resp3-key'),
|
||||
3
|
||||
);
|
||||
|
||||
assert.equal(await client.vCard('unknown'), 0);
|
||||
}, {
|
||||
...GLOBAL.SERVERS.OPEN,
|
||||
clientOptions: {
|
||||
RESP: 3
|
||||
},
|
||||
minimumDockerVersion: [8, 0]
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user