1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-07 13:22:56 +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 { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './LPOP'; import LPOP from './LPOP';
describe('LPOP', () => { describe('LPOP', () => {
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments('key'), LPOP.transformArguments('key'),
['LPOP', 'key'] ['LPOP', 'key']
); );
}); });
testUtils.testWithClient('client.lPop', async client => { testUtils.testAll('lPop', async client => {
assert.equal( assert.equal(
await client.lPop('key'), await client.lPop('key'),
null null
); );
}, GLOBAL.SERVERS.OPEN); }, {
client: GLOBAL.SERVERS.OPEN,
testUtils.testWithCluster('cluster.lPop', async cluster => { cluster: GLOBAL.CLUSTERS.OPEN
assert.equal( });
await cluster.lPop('key'),
null
);
}, GLOBAL.CLUSTERS.OPEN);
}); });

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,11 +1,11 @@
import { strict as assert } from 'assert'; import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils'; import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './RANDOMKEY'; import RANDOMKEY from './RANDOMKEY';
describe('RANDOMKEY', () => { describe('RANDOMKEY', () => {
it('transformArguments', () => { it('transformArguments', () => {
assert.deepEqual( assert.deepEqual(
transformArguments(), RANDOMKEY.transformArguments(),
['RANDOMKEY'] ['RANDOMKEY']
); );
}); });

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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