1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

some more commands

This commit is contained in:
Leibale
2023-04-30 10:33:05 -04:00
parent 53b9397a78
commit 88333c01de
25 changed files with 458 additions and 491 deletions

View File

@@ -1,26 +1,22 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LPOP';
import LPOP from './LPOP';
describe('LPOP', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key'),
['LPOP', 'key']
);
});
it('transformArguments', () => {
assert.deepEqual(
LPOP.transformArguments('key'),
['LPOP', 'key']
);
});
testUtils.testWithClient('client.lPop', async client => {
assert.equal(
await client.lPop('key'),
null
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.lPop', async cluster => {
assert.equal(
await cluster.lPop('key'),
null
);
}, GLOBAL.CLUSTERS.OPEN);
testUtils.testAll('lPop', async client => {
assert.equal(
await client.lPop('key'),
null
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,28 +1,24 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LPOP_COUNT';
import LPOP_COUNT from './LPOP_COUNT';
describe('LPOP COUNT', () => {
testUtils.isVersionGreaterThanHook([6, 2]);
testUtils.isVersionGreaterThanHook([6, 2]);
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', 1),
['LPOP', 'key', '1']
);
});
it('transformArguments', () => {
assert.deepEqual(
LPOP_COUNT.transformArguments('key', 1),
['LPOP', 'key', '1']
);
});
testUtils.testWithClient('client.lPopCount', async client => {
assert.equal(
await client.lPopCount('key', 1),
null
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.lPopCount', async cluster => {
assert.equal(
await cluster.lPopCount('key', 1),
null
);
}, GLOBAL.CLUSTERS.OPEN);
testUtils.testAll('lPopCount', async client => {
assert.equal(
await client.lPopCount('key', 1),
null
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,58 +1,54 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LPOS';
import LPOS from './LPOS';
describe('LPOS', () => {
testUtils.isVersionGreaterThanHook([6, 0, 6]);
testUtils.isVersionGreaterThanHook([6, 0, 6]);
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
transformArguments('key', 'element'),
['LPOS', 'key', 'element']
);
});
it('with RANK', () => {
assert.deepEqual(
transformArguments('key', 'element', {
RANK: 0
}),
['LPOS', 'key', 'element', 'RANK', '0']
);
});
it('with MAXLEN', () => {
assert.deepEqual(
transformArguments('key', 'element', {
MAXLEN: 10
}),
['LPOS', 'key', 'element', 'MAXLEN', '10']
);
});
it('with RANK, MAXLEN', () => {
assert.deepEqual(
transformArguments('key', 'element', {
RANK: 0,
MAXLEN: 10
}),
['LPOS', 'key', 'element', 'RANK', '0', 'MAXLEN', '10']
);
});
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
LPOS.transformArguments('key', 'element'),
['LPOS', 'key', 'element']
);
});
testUtils.testWithClient('client.lPos', async client => {
assert.equal(
await client.lPos('key', 'element'),
null
);
}, GLOBAL.SERVERS.OPEN);
it('with RANK', () => {
assert.deepEqual(
LPOS.transformArguments('key', 'element', {
RANK: 0
}),
['LPOS', 'key', 'element', 'RANK', '0']
);
});
testUtils.testWithCluster('cluster.lPos', async cluster => {
assert.equal(
await cluster.lPos('key', 'element'),
null
);
}, GLOBAL.CLUSTERS.OPEN);
it('with MAXLEN', () => {
assert.deepEqual(
LPOS.transformArguments('key', 'element', {
MAXLEN: 10
}),
['LPOS', 'key', 'element', 'MAXLEN', '10']
);
});
it('with RANK, MAXLEN', () => {
assert.deepEqual(
LPOS.transformArguments('key', 'element', {
RANK: 0,
MAXLEN: 10
}),
['LPOS', 'key', 'element', 'RANK', '0', 'MAXLEN', '10']
);
});
});
testUtils.testAll('lPos', async client => {
assert.equal(
await client.lPos('key', 'element'),
null
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,58 +1,54 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LPOS_COUNT';
import LPOS_COUNT from './LPOS_COUNT';
describe('LPOS COUNT', () => {
testUtils.isVersionGreaterThanHook([6, 0, 6]);
testUtils.isVersionGreaterThanHook([6, 0, 6]);
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
transformArguments('key', 'element', 0),
['LPOS', 'key', 'element', 'COUNT', '0']
);
});
it('with RANK', () => {
assert.deepEqual(
transformArguments('key', 'element', 0, {
RANK: 0
}),
['LPOS', 'key', 'element', 'RANK', '0', 'COUNT', '0']
);
});
it('with MAXLEN', () => {
assert.deepEqual(
transformArguments('key', 'element', 0, {
MAXLEN: 10
}),
['LPOS', 'key', 'element', 'COUNT', '0', 'MAXLEN', '10']
);
});
it('with RANK, MAXLEN', () => {
assert.deepEqual(
transformArguments('key', 'element', 0, {
RANK: 0,
MAXLEN: 10
}),
['LPOS', 'key', 'element', 'RANK', '0', 'COUNT', '0', 'MAXLEN', '10']
);
});
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
LPOS_COUNT.transformArguments('key', 'element', 0),
['LPOS', 'key', 'element', 'COUNT', '0']
);
});
testUtils.testWithClient('client.lPosCount', async client => {
assert.deepEqual(
await client.lPosCount('key', 'element', 0),
[]
);
}, GLOBAL.SERVERS.OPEN);
it('with RANK', () => {
assert.deepEqual(
LPOS_COUNT.transformArguments('key', 'element', 0, {
RANK: 0
}),
['LPOS', 'key', 'element', 'RANK', '0', 'COUNT', '0']
);
});
testUtils.testWithCluster('cluster.lPosCount', async cluster => {
assert.deepEqual(
await cluster.lPosCount('key', 'element', 0),
[]
);
}, GLOBAL.CLUSTERS.OPEN);
it('with MAXLEN', () => {
assert.deepEqual(
LPOS_COUNT.transformArguments('key', 'element', 0, {
MAXLEN: 10
}),
['LPOS', 'key', 'element', 'COUNT', '0', 'MAXLEN', '10']
);
});
it('with RANK, MAXLEN', () => {
assert.deepEqual(
LPOS_COUNT.transformArguments('key', 'element', 0, {
RANK: 0,
MAXLEN: 10
}),
['LPOS', 'key', 'element', 'RANK', '0', 'COUNT', '0', 'MAXLEN', '10']
);
});
});
testUtils.testAll('lPosCount', async client => {
assert.deepEqual(
await client.lPosCount('key', 'element', 0),
[]
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,35 +1,31 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LPUSH';
import LPUSH from './LPUSH';
describe('LPUSH', () => {
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
transformArguments('key', 'field'),
['LPUSH', 'key', 'field']
);
});
it('array', () => {
assert.deepEqual(
transformArguments('key', ['1', '2']),
['LPUSH', 'key', '1', '2']
);
});
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
LPUSH.transformArguments('key', 'field'),
['LPUSH', 'key', 'field']
);
});
testUtils.testWithClient('client.lPush', async client => {
assert.equal(
await client.lPush('key', 'field'),
1
);
}, GLOBAL.SERVERS.OPEN);
it('array', () => {
assert.deepEqual(
LPUSH.transformArguments('key', ['1', '2']),
['LPUSH', 'key', '1', '2']
);
});
});
testUtils.testWithCluster('cluster.lPush', async cluster => {
assert.equal(
await cluster.lPush('key', 'field'),
1
);
}, GLOBAL.CLUSTERS.OPEN);
testUtils.testAll('lPush', async client => {
assert.equal(
await client.lPush('key', 'field'),
1
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,35 +1,31 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LPUSHX';
import LPUSHX from './LPUSHX';
describe('LPUSHX', () => {
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
transformArguments('key', 'element'),
['LPUSHX', 'key', 'element']
);
});
it('array', () => {
assert.deepEqual(
transformArguments('key', ['1', '2']),
['LPUSHX', 'key', '1', '2']
);
});
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
LPUSHX.transformArguments('key', 'element'),
['LPUSHX', 'key', 'element']
);
});
testUtils.testWithClient('client.lPushX', async client => {
assert.equal(
await client.lPushX('key', 'element'),
0
);
}, GLOBAL.SERVERS.OPEN);
it('array', () => {
assert.deepEqual(
LPUSHX.transformArguments('key', ['1', '2']),
['LPUSHX', 'key', '1', '2']
);
});
});
testUtils.testWithCluster('cluster.lPushX', async cluster => {
assert.equal(
await cluster.lPushX('key', 'element'),
0
);
}, GLOBAL.CLUSTERS.OPEN);
testUtils.testAll('lPushX', async client => {
assert.equal(
await client.lPushX('key', 'element'),
0
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,27 +1,23 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LRANGE';
import LRANGE from './LRANGE';
describe('LRANGE', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', 0, -1),
['LRANGE', 'key', '0', '-1']
);
});
it('transformArguments', () => {
assert.deepEqual(
LRANGE.transformArguments('key', 0, -1),
['LRANGE', 'key', '0', '-1']
);
});
testUtils.testWithClient('client.lRange', async client => {
assert.deepEqual(
await client.lRange('key', 0, -1),
[]
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.lRange', async cluster => {
assert.deepEqual(
await cluster.lRange('key', 0, -1),
[]
);
}, GLOBAL.CLUSTERS.OPEN);
testUtils.testAll('lRange', async client => {
assert.deepEqual(
await client.lRange('key', 0, -1),
[]
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,27 +1,23 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LREM';
import LREM from './LREM';
describe('LREM', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', 0, 'element'),
['LREM', 'key', '0', 'element']
);
});
it('transformArguments', () => {
assert.deepEqual(
LREM.transformArguments('key', 0, 'element'),
['LREM', 'key', '0', 'element']
);
});
testUtils.testWithClient('client.lRem', async client => {
assert.equal(
await client.lRem('key', 0, 'element'),
0
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.lRem', async cluster => {
assert.equal(
await cluster.lRem('key', 0, 'element'),
0
);
}, GLOBAL.CLUSTERS.OPEN);
testUtils.testAll('lRem', async client => {
assert.equal(
await client.lRem('key', 0, 'element'),
0
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,28 +1,22 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LSET';
import LSET from './LSET';
describe('LSET', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', 0, 'element'),
['LSET', 'key', '0', 'element']
);
});
it('transformArguments', () => {
assert.deepEqual(
LSET.transformArguments('key', 0, 'element'),
['LSET', 'key', '0', 'element']
);
});
testUtils.testWithClient('client.lSet', async client => {
await client.lPush('key', 'element');
assert.equal(
await client.lSet('key', 0, 'element'),
'OK'
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.lSet', async cluster => {
await cluster.lPush('key', 'element');
assert.equal(
await cluster.lSet('key', 0, 'element'),
'OK'
);
}, GLOBAL.CLUSTERS.OPEN);
testUtils.testAll('lSet', async client => {
assert.equal(
await client.lSet('key', 0, 'element'),
'OK'
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,26 +1,22 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LTRIM';
import LTRIM from './LTRIM';
describe('LTRIM', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', 0, -1),
['LTRIM', 'key', '0', '-1']
);
});
it('transformArguments', () => {
assert.deepEqual(
LTRIM.transformArguments('key', 0, -1),
['LTRIM', 'key', '0', '-1']
);
});
testUtils.testWithClient('client.lTrim', async client => {
assert.equal(
await client.lTrim('key', 0, -1),
'OK'
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.lTrim', async cluster => {
assert.equal(
await cluster.lTrim('key', 0, -1),
'OK'
);
}, GLOBAL.CLUSTERS.OPEN);
testUtils.testAll('lTrim', async client => {
assert.equal(
await client.lTrim('key', 0, -1),
'OK'
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -5,7 +5,7 @@ export default {
transformArguments(
key: RedisArgument,
start: number,
stop: RedisArgument
stop: number
) {
return [
'LREM',

View File

@@ -1,26 +1,22 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './MGET';
import MGET from './MGET';
describe('MGET', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments(['1', '2']),
['MGET', '1', '2']
);
});
it('transformArguments', () => {
assert.deepEqual(
MGET.transformArguments(['1', '2']),
['MGET', '1', '2']
);
});
testUtils.testWithClient('client.mGet', async client => {
assert.deepEqual(
await client.mGet(['key']),
[null]
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.mGet', async cluster => {
assert.deepEqual(
await cluster.mGet(['key']),
[null]
);
}, GLOBAL.CLUSTERS.OPEN);
testUtils.testAll('mGet', async client => {
assert.deepEqual(
await client.mGet(['key']),
[null]
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,19 +1,19 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './RANDOMKEY';
import RANDOMKEY from './RANDOMKEY';
describe('RANDOMKEY', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments(),
['RANDOMKEY']
);
});
it('transformArguments', () => {
assert.deepEqual(
RANDOMKEY.transformArguments(),
['RANDOMKEY']
);
});
testUtils.testWithClient('client.randomKey', async client => {
assert.equal(
await client.randomKey(),
null
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('client.randomKey', async client => {
assert.equal(
await client.randomKey(),
null
);
}, GLOBAL.SERVERS.OPEN);
});

View File

@@ -1,21 +1,24 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './RENAME';
import RENAME from './RENAME';
describe('RENAME', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('from', 'to'),
['RENAME', 'from', 'to']
);
});
it('transformArguments', () => {
assert.deepEqual(
RENAME.transformArguments('source', 'destination'),
['RENAME', 'source', 'destination']
);
});
testUtils.testWithClient('client.rename', async client => {
await client.set('from', 'value');
assert.equal(
await client.rename('from', 'to'),
'OK'
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testAll('rename', async client => {
const [, reply] = await Promise.all([
client.set('{tag}source', 'value'),
client.rename('{tag}source', '{tag}destination')
]);
assert.equal(reply, 'OK');
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,21 +1,24 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './RENAMENX';
import RENAMENX from './RENAMENX';
describe('RENAMENX', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('from', 'to'),
['RENAMENX', 'from', 'to']
);
});
it('transformArguments', () => {
assert.deepEqual(
RENAMENX.transformArguments('source', 'destination'),
['RENAMENX', 'source', 'destination']
);
});
testUtils.testWithClient('client.renameNX', async client => {
await client.set('from', 'value');
testUtils.testAll('renameNX', async client => {
const [, reply] = await Promise.all([
client.set('{tag}source', 'value'),
client.renameNX('{tag}source', '{tag}destination')
]);
assert.equal(
await client.renameNX('from', 'to'),
true
);
}, GLOBAL.SERVERS.OPEN);
assert.equal(reply, 1);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,26 +1,22 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './RPOP';
import RPOP from './RPOP';
describe('RPOP', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key'),
['RPOP', 'key']
);
});
it('transformArguments', () => {
assert.deepEqual(
RPOP.transformArguments('key'),
['RPOP', 'key']
);
});
testUtils.testWithClient('client.rPop', async client => {
assert.equal(
await client.rPop('key'),
null
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.rPop', async cluster => {
assert.equal(
await cluster.rPop('key'),
null
);
}, GLOBAL.CLUSTERS.OPEN);
testUtils.testAll('rPop', async client => {
assert.equal(
await client.rPop('key'),
null
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,26 +1,22 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './RPOPLPUSH';
import RPOPLPUSH from './RPOPLPUSH';
describe('RPOPLPUSH', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('source', 'destination'),
['RPOPLPUSH', 'source', 'destination']
);
});
it('transformArguments', () => {
assert.deepEqual(
RPOPLPUSH.transformArguments('source', 'destination'),
['RPOPLPUSH', 'source', 'destination']
);
});
testUtils.testWithClient('client.rPopLPush', async client => {
assert.equal(
await client.rPopLPush('source', 'destination'),
null
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.rPopLPush', async cluster => {
assert.equal(
await cluster.rPopLPush('{tag}source', '{tag}destination'),
null
);
}, GLOBAL.CLUSTERS.OPEN);
testUtils.testAll('rPopLPush', async client => {
assert.equal(
await client.rPopLPush('{tag}source', '{tag}destination'),
null
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,28 +1,24 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './RPOP_COUNT';
import RPOP_COUNT from './RPOP_COUNT';
describe('RPOP COUNT', () => {
testUtils.isVersionGreaterThanHook([6, 2]);
testUtils.isVersionGreaterThanHook([6, 2]);
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', 1),
['RPOP', 'key', '1']
);
});
it('transformArguments', () => {
assert.deepEqual(
RPOP_COUNT.transformArguments('key', 1),
['RPOP', 'key', '1']
);
});
testUtils.testWithClient('client.rPopCount', async client => {
assert.equal(
await client.rPopCount('key', 1),
null
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testWithCluster('cluster.rPopCount', async cluster => {
assert.equal(
await cluster.rPopCount('key', 1),
null
);
}, GLOBAL.CLUSTERS.OPEN);
testUtils.testAll('rPopCount', async client => {
assert.equal(
await client.rPopCount('key', 1),
null
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,35 +1,31 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './RPUSH';
import RPUSH from './RPUSH';
describe('RPUSH', () => {
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
transformArguments('key', 'element'),
['RPUSH', 'key', 'element']
);
});
it('array', () => {
assert.deepEqual(
transformArguments('key', ['1', '2']),
['RPUSH', 'key', '1', '2']
);
});
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
RPUSH.transformArguments('key', 'element'),
['RPUSH', 'key', 'element']
);
});
testUtils.testWithClient('client.rPush', async client => {
assert.equal(
await client.rPush('key', 'element'),
1
);
}, GLOBAL.SERVERS.OPEN);
it('array', () => {
assert.deepEqual(
RPUSH.transformArguments('key', ['1', '2']),
['RPUSH', 'key', '1', '2']
);
});
});
testUtils.testWithCluster('cluster.rPush', async cluster => {
assert.equal(
await cluster.rPush('key', 'element'),
1
);
}, GLOBAL.CLUSTERS.OPEN);
testUtils.testAll('rPush', async client => {
assert.equal(
await client.rPush('key', 'element'),
1
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,11 +1,11 @@
import { RedisArgument, NumberReply, Command } from '../RESP/types';
import { pushVariadicArguments } from './generic-transformers';
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
export default {
FIRST_KEY_INDEX: 1,
transformArguments(
key: RedisArgument,
element: RedisArgument
element: RedisVariadicArgument
) {
return pushVariadicArguments(['RPUSH', key], element);
},

View File

@@ -1,35 +1,31 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './RPUSHX';
import RPUSHX from './RPUSHX';
describe('RPUSHX', () => {
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
transformArguments('key', 'element'),
['RPUSHX', 'key', 'element']
);
});
it('array', () => {
assert.deepEqual(
transformArguments('key', ['1', '2']),
['RPUSHX', 'key', '1', '2']
);
});
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
RPUSHX.transformArguments('key', 'element'),
['RPUSHX', 'key', 'element']
);
});
testUtils.testWithClient('client.rPushX', async client => {
assert.equal(
await client.rPushX('key', 'element'),
0
);
}, GLOBAL.SERVERS.OPEN);
it('array', () => {
assert.deepEqual(
RPUSHX.transformArguments('key', ['1', '2']),
['RPUSHX', 'key', '1', '2']
);
});
});
testUtils.testWithCluster('cluster.rPushX', async cluster => {
assert.equal(
await cluster.rPushX('key', 'element'),
0
);
}, GLOBAL.CLUSTERS.OPEN);
testUtils.testAll('rPushX', async client => {
assert.equal(
await client.rPushX('key', 'element'),
0
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,11 +1,11 @@
import { RedisArgument, NumberReply, Command } from '../RESP/types';
import { pushVariadicArguments } from './generic-transformers';
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
export default {
FIRST_KEY_INDEX: 1,
transformArguments(
key: RedisArgument,
element: RedisArgument
element: RedisVariadicArgument
) {
return pushVariadicArguments(['RPUSHX', key], element);
},

View File

@@ -1,28 +1,31 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './SADD';
import SADD from './SADD';
describe('SADD', () => {
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
transformArguments('key', 'member'),
['SADD', 'key', 'member']
);
});
it('array', () => {
assert.deepEqual(
transformArguments('key', ['1', '2']),
['SADD', 'key', '1', '2']
);
});
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
SADD.transformArguments('key', 'member'),
['SADD', 'key', 'member']
);
});
testUtils.testWithClient('client.sAdd', async client => {
assert.equal(
await client.sAdd('key', 'member'),
1
);
}, GLOBAL.SERVERS.OPEN);
it('array', () => {
assert.deepEqual(
SADD.transformArguments('key', ['1', '2']),
['SADD', 'key', '1', '2']
);
});
});
testUtils.testAll('sAdd', async client => {
assert.equal(
await client.sAdd('key', 'member'),
1
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,19 +1,22 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './SCARD';
import SCARD from './SCARD';
describe('SCARD', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key'),
['SCARD', 'key']
);
});
it('transformArguments', () => {
assert.deepEqual(
SCARD.transformArguments('key'),
['SCARD', 'key']
);
});
testUtils.testWithClient('client.sCard', async client => {
assert.equal(
await client.sCard('key'),
0
);
}, GLOBAL.SERVERS.OPEN);
testUtils.testAll('sCard', async client => {
assert.equal(
await client.sCard('key'),
0
);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -78,7 +78,9 @@ import LINSERT from './LINSERT';
import LLEN from './LLEN';
import LMOVE from './LMOVE';
import LMPOP from './LMPOP';
import LPOP_COUNT from './LPOP_COUNT';
import LPOP from './LPOP';
import LPOS_COUNT from './LPOS_COUNT';
import LPOS from './LPOS';
import LPUSH from './LPUSH';
import LPUSHX from './LPUSHX';
@@ -94,11 +96,16 @@ import PFCOUNT from './PFCOUNT';
import PFMERGE from './PFMERGE';
import PING from './PING';
import PSETEX from './PSETEX';
import RENAME from './RENAME';
import RENAMENX from './RENAMENX';
import RPOP_COUNT from './RPOP_COUNT';
import RPOP from './RPOP';
import RPOPLPUSH from './RPOPLPUSH';
import RPUSH from './RPUSH';
import RPUSHX from './RPUSHX';
import SADD from './SADD';
import SCAN from './SCAN';
import SCARD from './SCARD';
import SDIFF from './SDIFF';
import SDIFFSTORE from './SDIFFSTORE';
import SET from './SET';
@@ -312,8 +319,12 @@ export default {
lMove: LMOVE,
LMPOP,
lmPop: LMPOP,
LPOP_COUNT,
lPopCount: LPOP_COUNT,
LPOP,
lPop: LPOP,
LPOS_COUNT,
lPosCount: LPOS_COUNT,
LPOS,
lPos: LPOS,
LPUSH,
@@ -347,6 +358,12 @@ export default {
ping: PING,
PSETEX,
pSetEx: PSETEX,
RENAME,
rename: RENAME,
RENAMENX,
renameNX: RENAMENX,
RPOP_COUNT,
rPopCount: RPOP_COUNT,
RPOP,
rPop: RPOP,
RPOPLPUSH,
@@ -355,8 +372,12 @@ export default {
rPush: RPUSH,
RPUSHX,
rPushX: RPUSHX,
SADD,
sAdd: SADD,
SCAN,
scan: SCAN,
SCARD,
sCard: SCARD,
SDIFF,
sDiff: SDIFF,
SDIFFSTORE,