You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
Add Redis 8.2 New Stream Commands (#3029)
* chore: update Redis version from 8.2-RC1-pre to 8.2-rc1 * feat: implement XDELEX command for Redis 8.2 * feat: implement XACKDEL command for Redis 8.2 * refactor: create shared stream deletion types for Redis 8.2 commands * feat: add Redis 8.2 deletion policies to XTRIM command * feat: add Redis 8.2 deletion policies to XADD commands * fix: correct XDELEX command method name and test parameter
This commit is contained in:
@@ -2,6 +2,7 @@ import { strict as assert } from 'node:assert';
|
||||
import testUtils, { GLOBAL } from '../test-utils';
|
||||
import XTRIM from './XTRIM';
|
||||
import { parseArgs } from './generic-transformers';
|
||||
import { STREAM_DELETION_POLICY } from './common-stream.types';
|
||||
|
||||
describe('XTRIM', () => {
|
||||
describe('transformArguments', () => {
|
||||
@@ -12,6 +13,13 @@ describe('XTRIM', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('simple - MINID', () => {
|
||||
assert.deepEqual(
|
||||
parseArgs(XTRIM, 'key', 'MINID', 123),
|
||||
['XTRIM', 'key', 'MINID', '123']
|
||||
);
|
||||
});
|
||||
|
||||
it('with strategyModifier', () => {
|
||||
assert.deepEqual(
|
||||
parseArgs(XTRIM, 'key', 'MAXLEN', 1, {
|
||||
@@ -39,15 +47,96 @@ describe('XTRIM', () => {
|
||||
['XTRIM', 'key', 'MAXLEN', '=', '1', 'LIMIT', '1']
|
||||
);
|
||||
});
|
||||
|
||||
it('with policy', () => {
|
||||
assert.deepEqual(
|
||||
parseArgs(XTRIM, 'key', 'MAXLEN', 1, {
|
||||
policy: STREAM_DELETION_POLICY.DELREF
|
||||
}),
|
||||
['XTRIM', 'key', 'MAXLEN', '1', 'DELREF']
|
||||
);
|
||||
});
|
||||
|
||||
it('with all options', () => {
|
||||
assert.deepEqual(
|
||||
parseArgs(XTRIM, 'key', 'MAXLEN', 1, {
|
||||
strategyModifier: '~',
|
||||
LIMIT: 100,
|
||||
policy: STREAM_DELETION_POLICY.ACKED
|
||||
}),
|
||||
['XTRIM', 'key', 'MAXLEN', '~', '1', 'LIMIT', '100', 'ACKED']
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
testUtils.testAll('xTrim', async client => {
|
||||
testUtils.testAll('xTrim with MAXLEN', async client => {
|
||||
assert.equal(
|
||||
await client.xTrim('key', 'MAXLEN', 1),
|
||||
0
|
||||
typeof await client.xTrim('key', 'MAXLEN', 1),
|
||||
'number'
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN,
|
||||
});
|
||||
|
||||
testUtils.testAll('xTrim with MINID', async client => {
|
||||
assert.equal(
|
||||
typeof await client.xTrim('key', 'MINID', 1),
|
||||
'number'
|
||||
);
|
||||
}, {
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN,
|
||||
});
|
||||
|
||||
testUtils.testAll(
|
||||
'xTrim with LIMIT',
|
||||
async (client) => {
|
||||
assert.equal(
|
||||
typeof await client.xTrim('{tag}key', 'MAXLEN', 1000, {
|
||||
strategyModifier: '~',
|
||||
LIMIT: 10
|
||||
}),
|
||||
'number'
|
||||
);
|
||||
},
|
||||
{
|
||||
client: GLOBAL.SERVERS.OPEN,
|
||||
cluster: GLOBAL.CLUSTERS.OPEN,
|
||||
}
|
||||
);
|
||||
|
||||
testUtils.testAll(
|
||||
'xTrim with policy',
|
||||
async (client) => {
|
||||
assert.equal(
|
||||
typeof await client.xTrim('{tag}key', 'MAXLEN', 0, {
|
||||
policy: STREAM_DELETION_POLICY.DELREF
|
||||
}),
|
||||
'number'
|
||||
);
|
||||
},
|
||||
{
|
||||
client: { ...GLOBAL.SERVERS.OPEN, minimumDockerVersion: [8, 2] },
|
||||
cluster: { ...GLOBAL.CLUSTERS.OPEN, minimumDockerVersion: [8, 2] },
|
||||
}
|
||||
);
|
||||
|
||||
testUtils.testAll(
|
||||
'xTrim with all options',
|
||||
async (client) => {
|
||||
assert.equal(
|
||||
typeof await client.xTrim('{tag}key', 'MINID', 0, {
|
||||
strategyModifier: '~',
|
||||
LIMIT: 10,
|
||||
policy: STREAM_DELETION_POLICY.KEEPREF
|
||||
}),
|
||||
'number'
|
||||
);
|
||||
},
|
||||
{
|
||||
client: { ...GLOBAL.SERVERS.OPEN, minimumDockerVersion: [8, 2] },
|
||||
cluster: { ...GLOBAL.CLUSTERS.OPEN, minimumDockerVersion: [8, 2] },
|
||||
}
|
||||
);
|
||||
});
|
||||
|
Reference in New Issue
Block a user