1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-10 11:43:01 +03:00
This commit is contained in:
Leibale
2023-06-29 14:39:49 -04:00
parent ea2d9d2a77
commit c109fbf751
36 changed files with 584 additions and 720 deletions

View File

@@ -1,42 +1,59 @@
// import { strict as assert } from 'assert';
// import testUtils, { GLOBAL } from '../test-utils';
// import { transformArguments } from './XAUTOCLAIM';
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import XAUTOCLAIM from './XAUTOCLAIM';
// describe('XAUTOCLAIM', () => {
// testUtils.isVersionGreaterThanHook([6, 2]);
describe('XAUTOCLAIM', () => {
testUtils.isVersionGreaterThanHook([6, 2]);
// describe('transformArguments', () => {
// it('simple', () => {
// assert.deepEqual(
// transformArguments('key', 'group', 'consumer', 1, '0-0'),
// ['XAUTOCLAIM', 'key', 'group', 'consumer', '1', '0-0']
// );
// });
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
XAUTOCLAIM.transformArguments('key', 'group', 'consumer', 1, '0-0'),
['XAUTOCLAIM', 'key', 'group', 'consumer', '1', '0-0']
);
});
// it('with COUNT', () => {
// assert.deepEqual(
// transformArguments('key', 'group', 'consumer', 1, '0-0', {
// COUNT: 1
// }),
// ['XAUTOCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'COUNT', '1']
// );
// });
// });
it('with COUNT', () => {
assert.deepEqual(
XAUTOCLAIM.transformArguments('key', 'group', 'consumer', 1, '0-0', {
COUNT: 1
}),
['XAUTOCLAIM', 'key', 'group', 'consumer', '1', '0-0', 'COUNT', '1']
);
});
});
// testUtils.testWithClient('client.xAutoClaim', async client => {
// await Promise.all([
// client.xGroupCreate('key', 'group', '$', {
// MKSTREAM: true
// }),
// client.xGroupCreateConsumer('key', 'group', 'consumer'),
// ]);
testUtils.testAll('xAutoClaim', async client => {
const message = Object.create(null, {
field: {
value: 'value',
enumerable: true
}
});
// assert.deepEqual(
// await client.xAutoClaim('key', 'group', 'consumer', 1, '0-0'),
// {
// nextId: '0-0',
// messages: []
// }
// );
// }, GLOBAL.SERVERS.OPEN);
// });
const [, , id, , reply] = await Promise.all([
client.xGroupCreate('key', 'group', '$', {
MKSTREAM: true
}),
client.xGroupCreateConsumer('key', 'group', 'consumer'),
client.xAdd('key', '*', message),
client.xReadGroup('group', 'consumer', {
key: 'key',
id: '>'
}),
client.xAutoClaim('key', 'group', 'consumer', 0, '0-0')
]);
assert.deepEqual(reply, {
nextId: '0-0',
messages: [{
id,
message
}],
deletedMessages: testUtils.isVersionGreaterThan([7, 0]) ? [] : undefined
});
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});