1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +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,32 +1,49 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './BLMPOP';
import BLMPOP from './BLMPOP';
describe('BLMPOP', () => {
testUtils.isVersionGreaterThanHook([7]);
testUtils.isVersionGreaterThanHook([7]);
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
transformArguments(0, 'key', 'LEFT'),
['BLMPOP', '0', '1', 'key', 'LEFT']
);
});
it('with COUNT', () => {
assert.deepEqual(
transformArguments(0, 'key', 'LEFT', {
COUNT: 2
}),
['BLMPOP', '0', '1', 'key', 'LEFT', 'COUNT', '2']
);
});
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
BLMPOP.transformArguments(0, 'key', 'LEFT'),
['BLMPOP', '0', '1', 'key', 'LEFT']
);
});
testUtils.testWithClient('client.blmPop', async client => {
assert.deepEqual(
await client.blmPop(1, 'key', 'RIGHT'),
null
);
}, GLOBAL.SERVERS.OPEN);
it('with COUNT', () => {
assert.deepEqual(
BLMPOP.transformArguments(0, 'key', 'LEFT', {
COUNT: 1
}),
['BLMPOP', '0', '1', 'key', 'LEFT', 'COUNT', '1']
);
});
});
testUtils.testAll('blmPop - null', async client => {
assert.equal(
await client.blmPop(Number.MIN_VALUE, 'key', 'RIGHT'),
null
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
testUtils.testAll('blmPop - with member', async client => {
const [, reply] = await Promise.all([
client.lPush('key', 'element'),
client.blmPop(Number.MIN_VALUE, 'key', 'RIGHT')
]);
assert.deepEqual(reply, [
'key',
['element']
]);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});