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

some tests

This commit is contained in:
Leibale
2023-04-27 17:43:29 -04:00
parent 7bacad2e69
commit 53ac48f298
42 changed files with 1405 additions and 1259 deletions

View File

@@ -1,12 +1,12 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZADD';
import ZADD from './ZADD';
describe('ZADD', () => {
describe('transformArguments', () => {
it('single member', () => {
assert.deepEqual(
transformArguments('key', {
ZADD.transformArguments('key', {
value: '1',
score: 1
}),
@@ -16,7 +16,7 @@ describe('ZADD', () => {
it('multiple members', () => {
assert.deepEqual(
transformArguments('key', [{
ZADD.transformArguments('key', [{
value: '1',
score: 1
}, {
@@ -27,9 +27,22 @@ describe('ZADD', () => {
);
});
it('with NX', () => {
describe('with condition', () => {
it('condition property', () => {
assert.deepEqual(
transformArguments('key', {
ZADD.transformArguments('key', {
value: '1',
score: 1
}, {
condition: 'NX'
}),
['ZADD', 'key', 'NX', '1', '1']
);
});
it('with NX (backwards compatibility)', () => {
assert.deepEqual(
ZADD.transformArguments('key', {
value: '1',
score: 1
}, {
@@ -39,9 +52,9 @@ describe('ZADD', () => {
);
});
it('with XX', () => {
it('with XX (backwards compatibility)', () => {
assert.deepEqual(
transformArguments('key', {
ZADD.transformArguments('key', {
value: '1',
score: 1
}, {
@@ -50,22 +63,24 @@ describe('ZADD', () => {
['ZADD', 'key', 'XX', '1', '1']
);
});
});
it('with GT', () => {
describe('with comparison', () => {
it('with LT', () => {
assert.deepEqual(
transformArguments('key', {
ZADD.transformArguments('key', {
value: '1',
score: 1
}, {
GT: true
comparison: 'LT'
}),
['ZADD', 'key', 'GT', '1', '1']
['ZADD', 'key', 'LT', '1', '1']
);
});
it('with LT', () => {
it('with LT (backwards compatibility)', () => {
assert.deepEqual(
transformArguments('key', {
ZADD.transformArguments('key', {
value: '1',
score: 1
}, {
@@ -75,9 +90,22 @@ describe('ZADD', () => {
);
});
it('with GT (backwards compatibility)', () => {
assert.deepEqual(
ZADD.transformArguments('key', {
value: '1',
score: 1
}, {
GT: true
}),
['ZADD', 'key', 'GT', '1', '1']
);
});
});
it('with CH', () => {
assert.deepEqual(
transformArguments('key', {
ZADD.transformArguments('key', {
value: '1',
score: 1
}, {
@@ -89,7 +117,7 @@ describe('ZADD', () => {
it('with INCR', () => {
assert.deepEqual(
transformArguments('key', {
ZADD.transformArguments('key', {
value: '1',
score: 1
}, {
@@ -99,23 +127,23 @@ describe('ZADD', () => {
);
});
it('with XX, GT, CH, INCR', () => {
it('with condition, comparison, CH, INCR', () => {
assert.deepEqual(
transformArguments('key', {
ZADD.transformArguments('key', {
value: '1',
score: 1
}, {
XX: true,
GT: true,
condition: 'XX',
comparison: 'LT',
CH: true,
INCR: true
}),
['ZADD', 'key', 'XX', 'GT', 'CH', 'INCR', '1', '1']
['ZADD', 'key', 'XX', 'LT', 'CH', 'INCR', '1', '1']
);
});
});
testUtils.testWithClient('client.zAdd', async client => {
testUtils.testAll('zAdd', async client => {
assert.equal(
await client.zAdd('key', {
value: '1',
@@ -123,5 +151,8 @@ describe('ZADD', () => {
}),
1
);
}, GLOBAL.SERVERS.OPEN);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,32 +1,29 @@
import { RedisArgument, NumberReply, DoubleReply, Command } from '../RESP/types';
import { ZMember, transformDoubleArgument, transformDoubleReply } from './generic-transformers';
interface NX {
export interface ZAddOptions {
condition?: 'NX' | 'XX';
/**
* @deprecated Use `{ condition: 'NX' }` instead.
*/
NX?: boolean;
}
interface XX {
/**
* @deprecated Use `{ condition: 'XX' }` instead.
*/
XX?: boolean;
}
interface LT {
comparison?: 'LT' | 'GT';
/**
* @deprecated Use `{ comparison: 'LT' }` instead.
*/
LT?: boolean;
}
interface GT {
/**
* @deprecated Use `{ comparison: 'GT' }` instead.
*/
GT?: boolean;
}
interface CH {
CH?: boolean;
}
interface INCR {
INCR?: boolean;
}
export type ZAddOptions = (NX | (XX & LT & GT)) & CH & INCR;
export default {
FIRST_KEY_INDEX: 1,
transformArguments(
@@ -36,35 +33,36 @@ export default {
) {
const args = ['ZADD', key];
if ((<NX>options)?.NX) {
if (options?.condition) {
args.push(options.condition);
} else if (options?.NX) {
args.push('NX');
} else {
if ((<XX>options)?.XX) {
} else if (options?.XX) {
args.push('XX');
}
if ((<GT>options)?.GT) {
if (options?.comparison) {
args.push(options.comparison);
} else if (options?.LT) {
args.push('LT');
} else if (options?.GT) {
args.push('GT');
}
if ((<LT>options)?.LT) {
args.push('LT');
}
}
if ((<CH>options)?.CH) {
if (options?.CH) {
args.push('CH');
}
if ((<INCR>options)?.INCR) {
if (options?.INCR) {
args.push('INCR');
}
for (const { score, value } of (Array.isArray(members) ? members : [members])) {
args.push(
transformDoubleArgument(score),
value
);
if (Array.isArray(members)) {
for (const member of members) {
pushMember(args, member);
}
} else {
pushMember(args, members);
}
return args;
@@ -74,3 +72,10 @@ export default {
3: undefined as unknown as () => NumberReply | DoubleReply
}
} as const satisfies Command;
function pushMember(args: Array<RedisArgument>, member: ZMember) {
args.push(
transformDoubleArgument(member.score),
member.value
);
}

View File

@@ -1,19 +1,22 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZCARD';
import ZCARD from './ZCARD';
describe('ZCARD', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key'),
ZCARD.transformArguments('key'),
['ZCARD', 'key']
);
});
testUtils.testWithClient('client.zCard', async client => {
testUtils.testAll('zCard', async client => {
assert.equal(
await client.zCard('key'),
0
);
}, GLOBAL.SERVERS.OPEN);
}, {
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 './ZCOUNT';
import ZCOUNT from './ZCOUNT';
describe('ZCOUNT', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', 0, 1),
ZCOUNT.transformArguments('key', 0, 1),
['ZCOUNT', 'key', '0', '1']
);
});
testUtils.testWithClient('client.zCount', async client => {
testUtils.testAll('zCount', async client => {
assert.equal(
await client.zCount('key', 0, 1),
0
);
}, GLOBAL.SERVERS.OPEN);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.SERVERS.OPEN
});
});

View File

@@ -1,6 +1,6 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZDIFF';
import ZDIFF from './ZDIFF';
describe('ZDIFF', () => {
testUtils.isVersionGreaterThanHook([6, 2]);
@@ -8,23 +8,26 @@ describe('ZDIFF', () => {
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
transformArguments('key'),
ZDIFF.transformArguments('key'),
['ZDIFF', '1', 'key']
);
});
it('array', () => {
assert.deepEqual(
transformArguments(['1', '2']),
ZDIFF.transformArguments(['1', '2']),
['ZDIFF', '2', '1', '2']
);
});
});
testUtils.testWithClient('client.zDiff', async client => {
testUtils.testAll('zDiff', async client => {
assert.deepEqual(
await client.zDiff('key'),
[]
);
}, GLOBAL.SERVERS.OPEN);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,6 +1,6 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZDIFFSTORE';
import ZDIFFSTORE from './ZDIFFSTORE';
describe('ZDIFFSTORE', () => {
testUtils.isVersionGreaterThanHook([6, 2]);
@@ -8,23 +8,26 @@ describe('ZDIFFSTORE', () => {
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
transformArguments('destination', 'key'),
ZDIFFSTORE.transformArguments('destination', 'key'),
['ZDIFFSTORE', 'destination', '1', 'key']
);
});
it('array', () => {
assert.deepEqual(
transformArguments('destination', ['1', '2']),
ZDIFFSTORE.transformArguments('destination', ['1', '2']),
['ZDIFFSTORE', 'destination', '2', '1', '2']
);
});
});
testUtils.testWithClient('client.zDiffStore', async client => {
testUtils.testAll('zDiffStore', async client => {
assert.equal(
await client.zDiffStore('destination', 'key'),
await client.zDiffStore('{tag}destination', '{tag}key'),
0
);
}, GLOBAL.SERVERS.OPEN);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,6 +1,6 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZDIFF_WITHSCORES';
import ZDIFF_WITHSCORES from './ZDIFF_WITHSCORES';
describe('ZDIFF WITHSCORES', () => {
testUtils.isVersionGreaterThanHook([6, 2]);
@@ -8,23 +8,26 @@ describe('ZDIFF WITHSCORES', () => {
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
transformArguments('key'),
ZDIFF_WITHSCORES.transformArguments('key'),
['ZDIFF', '1', 'key', 'WITHSCORES']
);
});
it('array', () => {
assert.deepEqual(
transformArguments(['1', '2']),
ZDIFF_WITHSCORES.transformArguments(['1', '2']),
['ZDIFF', '2', '1', '2', 'WITHSCORES']
);
});
});
testUtils.testWithClient('client.zDiffWithScores', async client => {
testUtils.testAll('zDiffWithScores', async client => {
assert.deepEqual(
await client.zDiffWithScores('key'),
[]
);
}, GLOBAL.SERVERS.OPEN);
}, {
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 './ZINCRBY';
import ZINCRBY from './ZINCRBY';
describe('ZINCRBY', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', 1, 'member'),
ZINCRBY.transformArguments('key', 1, 'member'),
['ZINCRBY', 'key', '1', 'member']
);
});
testUtils.testWithClient('client.zIncrBy', async client => {
testUtils.testAll('zIncrBy', async client => {
assert.equal(
await client.zIncrBy('destination', 1, 'member'),
1
);
}, GLOBAL.SERVERS.OPEN);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,6 +1,6 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZINTER';
import ZINTER from './ZINTER';
describe('ZINTER', () => {
testUtils.isVersionGreaterThanHook([6, 2]);
@@ -8,51 +8,58 @@ describe('ZINTER', () => {
describe('transformArguments', () => {
it('key (string)', () => {
assert.deepEqual(
transformArguments('key'),
ZINTER.transformArguments('key'),
['ZINTER', '1', 'key']
);
});
it('keys (array)', () => {
it('keys (Array<string>)', () => {
assert.deepEqual(
transformArguments(['1', '2']),
ZINTER.transformArguments(['1', '2']),
['ZINTER', '2', '1', '2']
);
});
it('with WEIGHTS', () => {
it('key & weight', () => {
assert.deepEqual(
transformArguments('key', {
WEIGHTS: [1]
ZINTER.transformArguments({
key: 'key',
weight: 1
}),
['ZINTER', '1', 'key', 'WEIGHTS', '1']
);
});
it('keys & weights', () => {
assert.deepEqual(
ZINTER.transformArguments([{
key: 'a',
weight: 1
}, {
key: 'b',
weight: 2
}]),
['ZINTER', '2', 'a', 'b', 'WEIGHTS', '1', '2']
);
});
it('with AGGREGATE', () => {
assert.deepEqual(
transformArguments('key', {
ZINTER.transformArguments('key', {
AGGREGATE: 'SUM'
}),
['ZINTER', '1', 'key', 'AGGREGATE', 'SUM']
);
});
it('with WEIGHTS, AGGREGATE', () => {
assert.deepEqual(
transformArguments('key', {
WEIGHTS: [1],
AGGREGATE: 'SUM'
}),
['ZINTER', '1', 'key', 'WEIGHTS', '1', 'AGGREGATE', 'SUM']
);
});
});
testUtils.testWithClient('client.zInter', async client => {
testUtils.testAll('zInter', async client => {
assert.deepEqual(
await client.zInter('key'),
[]
);
}, GLOBAL.SERVERS.OPEN);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,6 +1,6 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZINTERCARD';
import ZINTERCARD from './ZINTERCARD';
describe('ZINTERCARD', () => {
testUtils.isVersionGreaterThanHook([7]);
@@ -8,23 +8,26 @@ describe('ZINTERCARD', () => {
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
transformArguments(['1', '2']),
ZINTERCARD.transformArguments(['1', '2']),
['ZINTERCARD', '2', '1', '2']
);
});
it('with limit', () => {
assert.deepEqual(
transformArguments(['1', '2'], 1),
ZINTERCARD.transformArguments(['1', '2'], 1),
['ZINTERCARD', '2', '1', '2', 'LIMIT', '1']
);
});
});
testUtils.testWithClient('client.zInterCard', async client => {
testUtils.testAll('zInterCard', async client => {
assert.deepEqual(
await client.zInterCard('key'),
0
);
}, GLOBAL.SERVERS.OPEN);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,56 +1,63 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZINTERSTORE';
import ZINTERSTORE from './ZINTERSTORE';
describe('ZINTERSTORE', () => {
describe('transformArguments', () => {
it('key (string)', () => {
assert.deepEqual(
transformArguments('destination', 'key'),
ZINTERSTORE.transformArguments('destination', 'key'),
['ZINTERSTORE', 'destination', '1', 'key']
);
});
it('keys (array)', () => {
it('keys (Array<string>)', () => {
assert.deepEqual(
transformArguments('destination', ['1', '2']),
ZINTERSTORE.transformArguments('destination', ['1', '2']),
['ZINTERSTORE', 'destination', '2', '1', '2']
);
});
it('with WEIGHTS', () => {
it('key & weight', () => {
assert.deepEqual(
transformArguments('destination', 'key', {
WEIGHTS: [1]
ZINTERSTORE.transformArguments('destination', {
key: 'key',
weight: 1
}),
['ZINTERSTORE', 'destination', '1', 'key', 'WEIGHTS', '1']
);
});
it('keys & weights', () => {
assert.deepEqual(
ZINTERSTORE.transformArguments('destination', [{
key: 'a',
weight: 1
}, {
key: 'b',
weight: 2
}]),
['ZINTERSTORE', 'destination', '2', 'a', 'b', 'WEIGHTS', '1', '2']
);
});
it('with AGGREGATE', () => {
assert.deepEqual(
transformArguments('destination', 'key', {
ZINTERSTORE.transformArguments('destination', 'key', {
AGGREGATE: 'SUM'
}),
['ZINTERSTORE', 'destination', '1', 'key', 'AGGREGATE', 'SUM']
);
});
it('with WEIGHTS, AGGREGATE', () => {
assert.deepEqual(
transformArguments('destination', 'key', {
WEIGHTS: [1],
AGGREGATE: 'SUM'
}),
['ZINTERSTORE', 'destination', '1', 'key', 'WEIGHTS', '1', 'AGGREGATE', 'SUM']
);
});
});
testUtils.testWithClient('client.zInterStore', async client => {
testUtils.testAll('zInterStore', async client => {
assert.equal(
await client.zInterStore('destination', 'key'),
await client.zInterStore('{tag}destination', '{tag}key'),
0
);
}, GLOBAL.SERVERS.OPEN);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,6 +1,6 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZINTER_WITHSCORES';
import ZINTER_WITHSCORES from './ZINTER_WITHSCORES';
describe('ZINTER WITHSCORES', () => {
testUtils.isVersionGreaterThanHook([6, 2]);
@@ -8,51 +8,58 @@ describe('ZINTER WITHSCORES', () => {
describe('transformArguments', () => {
it('key (string)', () => {
assert.deepEqual(
transformArguments('key'),
ZINTER_WITHSCORES.transformArguments('key'),
['ZINTER', '1', 'key', 'WITHSCORES']
);
});
it('keys (array)', () => {
it('keys (Array<string>)', () => {
assert.deepEqual(
transformArguments(['1', '2']),
ZINTER_WITHSCORES.transformArguments(['1', '2']),
['ZINTER', '2', '1', '2', 'WITHSCORES']
);
});
it('with WEIGHTS', () => {
it('key & weight', () => {
assert.deepEqual(
transformArguments('key', {
WEIGHTS: [1]
ZINTER_WITHSCORES.transformArguments({
key: 'key',
weight: 1
}),
['ZINTER', '1', 'key', 'WEIGHTS', '1', 'WITHSCORES']
);
});
it('keys & weights', () => {
assert.deepEqual(
ZINTER_WITHSCORES.transformArguments([{
key: 'a',
weight: 1
}, {
key: 'b',
weight: 2
}]),
['ZINTER', '2', 'a', 'b', 'WEIGHTS', '1', '2', 'WITHSCORES']
);
});
it('with AGGREGATE', () => {
assert.deepEqual(
transformArguments('key', {
ZINTER_WITHSCORES.transformArguments('key', {
AGGREGATE: 'SUM'
}),
['ZINTER', '1', 'key', 'AGGREGATE', 'SUM', 'WITHSCORES']
);
});
it('with WEIGHTS, AGGREGATE', () => {
assert.deepEqual(
transformArguments('key', {
WEIGHTS: [1],
AGGREGATE: 'SUM'
}),
['ZINTER', '1', 'key', 'WEIGHTS', '1', 'AGGREGATE', 'SUM', 'WITHSCORES']
);
});
});
testUtils.testWithClient('client.zInterWithScores', async client => {
testUtils.testAll('zInterWithScores', async client => {
assert.deepEqual(
await client.zInterWithScores('key'),
[]
);
}, GLOBAL.SERVERS.OPEN);
}, {
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 './ZLEXCOUNT';
import ZLEXCOUNT from './ZLEXCOUNT';
describe('ZLEXCOUNT', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', '[a', '[b'),
ZLEXCOUNT.transformArguments('key', '[a', '[b'),
['ZLEXCOUNT', 'key', '[a', '[b']
);
});
testUtils.testWithClient('client.zLexCount', async client => {
testUtils.testAll('zLexCount', async client => {
assert.equal(
await client.zLexCount('key', '[a', '[b'),
0
);
}, GLOBAL.SERVERS.OPEN);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,32 +1,32 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZMPOP';
// import { strict as assert } from 'assert';
// import testUtils, { GLOBAL } from '../test-utils';
// import { transformArguments } from './ZMPOP';
describe('ZMPOP', () => {
testUtils.isVersionGreaterThanHook([7]);
// describe('ZMPOP', () => {
// testUtils.isVersionGreaterThanHook([7]);
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
transformArguments('key', 'MIN'),
['ZMPOP', '1', 'key', 'MIN']
);
});
// describe('transformArguments', () => {
// it('simple', () => {
// assert.deepEqual(
// transformArguments('key', 'MIN'),
// ['ZMPOP', '1', 'key', 'MIN']
// );
// });
it('with score and count', () => {
assert.deepEqual(
transformArguments('key', 'MIN', {
COUNT: 2
}),
['ZMPOP', '1', 'key', 'MIN', 'COUNT', '2']
);
});
});
// it('with score and count', () => {
// assert.deepEqual(
// transformArguments('key', 'MIN', {
// COUNT: 2
// }),
// ['ZMPOP', '1', 'key', 'MIN', 'COUNT', '2']
// );
// });
// });
testUtils.testWithClient('client.zmPop', async client => {
assert.deepEqual(
await client.zmPop('key', 'MIN'),
null
);
}, GLOBAL.SERVERS.OPEN);
});
// testUtils.testWithClient('client.zmPop', async client => {
// assert.deepEqual(
// await client.zmPop('key', 'MIN'),
// null
// );
// }, GLOBAL.SERVERS.OPEN);
// });

View File

@@ -1,6 +1,6 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZMSCORE';
import ZMSCORE from './ZMSCORE';
describe('ZMSCORE', () => {
testUtils.isVersionGreaterThanHook([6, 2]);
@@ -8,23 +8,26 @@ describe('ZMSCORE', () => {
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
transformArguments('key', 'member'),
ZMSCORE.transformArguments('key', 'member'),
['ZMSCORE', 'key', 'member']
);
});
it('array', () => {
assert.deepEqual(
transformArguments('key', ['1', '2']),
ZMSCORE.transformArguments('key', ['1', '2']),
['ZMSCORE', 'key', '1', '2']
);
});
});
testUtils.testWithClient('client.zmScore', async client => {
testUtils.testAll('zmScore', async client => {
assert.deepEqual(
await client.zmScore('key', 'member'),
[null]
);
}, GLOBAL.SERVERS.OPEN);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,5 +1,5 @@
import { RedisArgument, ArrayReply, NullReply, BlobStringReply, DoubleReply, Command } from '../RESP/types';
import { pushVariadicArgument, RedisVariadicArgument } from './generic-transformers';
import { pushVariadicArguments, RedisVariadicArgument } from './generic-transformers';
export default {
FIRST_KEY_INDEX: 1,
@@ -8,7 +8,7 @@ export default {
key: RedisArgument,
member: RedisVariadicArgument
) {
return pushVariadicArgument(['ZMSCORE', key], member);
return pushVariadicArguments(['ZMSCORE', key], member);
},
transformReply: {
2: (reply: ArrayReply<NullReply | BlobStringReply>) => {

View File

@@ -1,41 +1,41 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './ZPOPMAX';
// import { strict as assert } from 'assert';
// import testUtils, { GLOBAL } from '../test-utils';
// import { transformArguments, transformReply } from './ZPOPMAX';
describe('ZPOPMAX', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key'),
['ZPOPMAX', 'key']
);
});
// describe('ZPOPMAX', () => {
// it('transformArguments', () => {
// assert.deepEqual(
// transformArguments('key'),
// ['ZPOPMAX', 'key']
// );
// });
it('transformReply', () => {
assert.deepEqual(
transformReply(['value', '1']),
{
value: 'value',
score: 1
}
);
});
// it('transformReply', () => {
// assert.deepEqual(
// transformReply(['value', '1']),
// {
// value: 'value',
// score: 1
// }
// );
// });
describe('client.zPopMax', () => {
testUtils.testWithClient('null', async client => {
assert.equal(
await client.zPopMax('key'),
null
);
}, GLOBAL.SERVERS.OPEN);
// describe('client.zPopMax', () => {
// testUtils.testWithClient('null', async client => {
// assert.equal(
// await client.zPopMax('key'),
// null
// );
// }, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('member', async client => {
const member = { score: 1, value: 'value' },
[, zPopMaxReply] = await Promise.all([
client.zAdd('key', member),
client.zPopMax('key')
]);
// testUtils.testWithClient('member', async client => {
// const member = { score: 1, value: 'value' },
// [, zPopMaxReply] = await Promise.all([
// client.zAdd('key', member),
// client.zPopMax('key')
// ]);
assert.deepEqual(zPopMaxReply, member);
}, GLOBAL.SERVERS.OPEN);
});
});
// assert.deepEqual(zPopMaxReply, member);
// }, GLOBAL.SERVERS.OPEN);
// });
// });

View File

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

View File

@@ -1,41 +1,41 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './ZPOPMIN';
// import { strict as assert } from 'assert';
// import testUtils, { GLOBAL } from '../test-utils';
// import { transformArguments, transformReply } from './ZPOPMIN';
describe('ZPOPMIN', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key'),
['ZPOPMIN', 'key']
);
});
// describe('ZPOPMIN', () => {
// it('transformArguments', () => {
// assert.deepEqual(
// transformArguments('key'),
// ['ZPOPMIN', 'key']
// );
// });
it('transformReply', () => {
assert.deepEqual(
transformReply(['value', '1']),
{
value: 'value',
score: 1
}
);
});
// it('transformReply', () => {
// assert.deepEqual(
// transformReply(['value', '1']),
// {
// value: 'value',
// score: 1
// }
// );
// });
describe('client.zPopMin', () => {
testUtils.testWithClient('null', async client => {
assert.equal(
await client.zPopMin('key'),
null
);
}, GLOBAL.SERVERS.OPEN);
// describe('client.zPopMin', () => {
// testUtils.testWithClient('null', async client => {
// assert.equal(
// await client.zPopMin('key'),
// null
// );
// }, GLOBAL.SERVERS.OPEN);
testUtils.testWithClient('member', async client => {
const member = { score: 1, value: 'value' },
[, zPopMinReply] = await Promise.all([
client.zAdd('key', member),
client.zPopMin('key')
]);
// testUtils.testWithClient('member', async client => {
// const member = { score: 1, value: 'value' },
// [, zPopMinReply] = await Promise.all([
// client.zAdd('key', member),
// client.zPopMin('key')
// ]);
assert.deepEqual(zPopMinReply, member);
}, GLOBAL.SERVERS.OPEN);
});
});
// assert.deepEqual(zPopMinReply, member);
// }, GLOBAL.SERVERS.OPEN);
// });
// });

View File

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

View File

@@ -1,21 +1,24 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZRANDMEMBER';
import ZRANDMEMBER from './ZRANDMEMBER';
describe('ZRANDMEMBER', () => {
testUtils.isVersionGreaterThanHook([6, 2]);
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key'),
ZRANDMEMBER.transformArguments('key'),
['ZRANDMEMBER', 'key']
);
});
testUtils.testWithClient('client.zRandMember', async client => {
testUtils.testAll('zRandMember', async client => {
assert.equal(
await client.zRandMember('key'),
null
);
}, GLOBAL.SERVERS.OPEN);
}, {
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 './ZRANDMEMBER_COUNT';
import ZRANDMEMBER_COUNT from './ZRANDMEMBER_COUNT';
describe('ZRANDMEMBER COUNT', () => {
testUtils.isVersionGreaterThanHook([6, 2, 5]);
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', 1),
ZRANDMEMBER_COUNT.transformArguments('key', 1),
['ZRANDMEMBER', 'key', '1']
);
});
testUtils.testWithClient('client.zRandMemberCount', async client => {
testUtils.testAll('zRandMemberCount', async client => {
assert.deepEqual(
await client.zRandMemberCount('key', 1),
[]
);
}, GLOBAL.SERVERS.OPEN);
}, {
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 './ZRANDMEMBER_COUNT_WITHSCORES';
import ZRANDMEMBER_COUNT_WITHSCORES from './ZRANDMEMBER_COUNT_WITHSCORES';
describe('ZRANDMEMBER COUNT WITHSCORES', () => {
testUtils.isVersionGreaterThanHook([6, 2, 5]);
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', 1),
ZRANDMEMBER_COUNT_WITHSCORES.transformArguments('key', 1),
['ZRANDMEMBER', 'key', '1', 'WITHSCORES']
);
});
testUtils.testWithClient('client.zRandMemberCountWithScores', async client => {
testUtils.testAll('zRandMemberCountWithScores', async client => {
assert.deepEqual(
await client.zRandMemberCountWithScores('key', 1),
[]
);
}, GLOBAL.SERVERS.OPEN);
}, {
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 './ZRANGE';
import ZRANGE from './ZRANGE';
describe('ZRANGE', () => {
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
transformArguments('src', 0, 1),
ZRANGE.transformArguments('src', 0, 1),
['ZRANGE', 'src', '0', '1']
);
});
it('with BYSCORE', () => {
assert.deepEqual(
transformArguments('src', 0, 1, {
ZRANGE.transformArguments('src', 0, 1, {
BY: 'SCORE'
}),
['ZRANGE', 'src', '0', '1', 'BYSCORE']
@@ -22,7 +22,7 @@ describe('ZRANGE', () => {
it('with BYLEX', () => {
assert.deepEqual(
transformArguments('src', 0, 1, {
ZRANGE.transformArguments('src', 0, 1, {
BY: 'LEX'
}),
['ZRANGE', 'src', '0', '1', 'BYLEX']
@@ -31,7 +31,7 @@ describe('ZRANGE', () => {
it('with REV', () => {
assert.deepEqual(
transformArguments('src', 0, 1, {
ZRANGE.transformArguments('src', 0, 1, {
REV: true
}),
['ZRANGE', 'src', '0', '1', 'REV']
@@ -40,7 +40,7 @@ describe('ZRANGE', () => {
it('with LIMIT', () => {
assert.deepEqual(
transformArguments('src', 0, 1, {
ZRANGE.transformArguments('src', 0, 1, {
LIMIT: {
offset: 0,
count: 1
@@ -52,7 +52,7 @@ describe('ZRANGE', () => {
it('with BY & REV & LIMIT', () => {
assert.deepEqual(
transformArguments('src', 0, 1, {
ZRANGE.transformArguments('src', 0, 1, {
BY: 'SCORE',
REV: true,
LIMIT: {
@@ -65,10 +65,13 @@ describe('ZRANGE', () => {
});
});
testUtils.testWithClient('client.zRange', async client => {
testUtils.testAll('zRange', async client => {
assert.deepEqual(
await client.zRange('src', 0, 1),
[]
);
}, GLOBAL.SERVERS.OPEN);
}, {
client: GLOBAL.SERVERS.OPEN,
cluster: GLOBAL.CLUSTERS.OPEN
});
});

View File

@@ -1,7 +1,7 @@
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '../RESP/types';
import { transformStringDoubleArgument } from './generic-transformers';
interface ZRangeOptions {
export interface ZRangeOptions {
BY?: 'SCORE' | 'LEX';
REV?: boolean;
LIMIT?: {

View File

@@ -1,33 +1,33 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZRANGEBYLEX';
// import { strict as assert } from 'assert';
// import testUtils, { GLOBAL } from '../test-utils';
// import { transformArguments } from './ZRANGEBYLEX';
describe('ZRANGEBYLEX', () => {
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
transformArguments('src', '-', '+'),
['ZRANGEBYLEX', 'src', '-', '+']
);
});
// describe('ZRANGEBYLEX', () => {
// describe('transformArguments', () => {
// it('simple', () => {
// assert.deepEqual(
// transformArguments('src', '-', '+'),
// ['ZRANGEBYLEX', 'src', '-', '+']
// );
// });
it('with LIMIT', () => {
assert.deepEqual(
transformArguments('src', '-', '+', {
LIMIT: {
offset: 0,
count: 1
}
}),
['ZRANGEBYLEX', 'src', '-', '+', 'LIMIT', '0', '1']
);
});
});
// it('with LIMIT', () => {
// assert.deepEqual(
// transformArguments('src', '-', '+', {
// LIMIT: {
// offset: 0,
// count: 1
// }
// }),
// ['ZRANGEBYLEX', 'src', '-', '+', 'LIMIT', '0', '1']
// );
// });
// });
testUtils.testWithClient('client.zRangeByLex', async client => {
assert.deepEqual(
await client.zRangeByLex('src', '-', '+'),
[]
);
}, GLOBAL.SERVERS.OPEN);
});
// testUtils.testWithClient('client.zRangeByLex', async client => {
// assert.deepEqual(
// await client.zRangeByLex('src', '-', '+'),
// []
// );
// }, GLOBAL.SERVERS.OPEN);
// });

View File

@@ -1,33 +1,33 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZRANGEBYSCORE';
// import { strict as assert } from 'assert';
// import testUtils, { GLOBAL } from '../test-utils';
// import { transformArguments } from './ZRANGEBYSCORE';
describe('ZRANGEBYSCORE', () => {
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
transformArguments('src', 0, 1),
['ZRANGEBYSCORE', 'src', '0', '1']
);
});
// describe('ZRANGEBYSCORE', () => {
// describe('transformArguments', () => {
// it('simple', () => {
// assert.deepEqual(
// transformArguments('src', 0, 1),
// ['ZRANGEBYSCORE', 'src', '0', '1']
// );
// });
it('with LIMIT', () => {
assert.deepEqual(
transformArguments('src', 0, 1, {
LIMIT: {
offset: 0,
count: 1
}
}),
['ZRANGEBYSCORE', 'src', '0', '1', 'LIMIT', '0', '1']
);
});
});
// it('with LIMIT', () => {
// assert.deepEqual(
// transformArguments('src', 0, 1, {
// LIMIT: {
// offset: 0,
// count: 1
// }
// }),
// ['ZRANGEBYSCORE', 'src', '0', '1', 'LIMIT', '0', '1']
// );
// });
// });
testUtils.testWithClient('client.zRangeByScore', async client => {
assert.deepEqual(
await client.zRangeByScore('src', 0, 1),
[]
);
}, GLOBAL.SERVERS.OPEN);
});
// testUtils.testWithClient('client.zRangeByScore', async client => {
// assert.deepEqual(
// await client.zRangeByScore('src', 0, 1),
// []
// );
// }, GLOBAL.SERVERS.OPEN);
// });

View File

@@ -1,33 +1,33 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZRANGEBYSCORE_WITHSCORES';
// import { strict as assert } from 'assert';
// import testUtils, { GLOBAL } from '../test-utils';
// import { transformArguments } from './ZRANGEBYSCORE_WITHSCORES';
describe('ZRANGEBYSCORE WITHSCORES', () => {
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
transformArguments('src', 0, 1),
['ZRANGEBYSCORE', 'src', '0', '1', 'WITHSCORES']
);
});
// describe('ZRANGEBYSCORE WITHSCORES', () => {
// describe('transformArguments', () => {
// it('simple', () => {
// assert.deepEqual(
// transformArguments('src', 0, 1),
// ['ZRANGEBYSCORE', 'src', '0', '1', 'WITHSCORES']
// );
// });
it('with LIMIT', () => {
assert.deepEqual(
transformArguments('src', 0, 1, {
LIMIT: {
offset: 0,
count: 1
}
}),
['ZRANGEBYSCORE', 'src', '0', '1', 'LIMIT', '0', '1', 'WITHSCORES']
);
});
});
// it('with LIMIT', () => {
// assert.deepEqual(
// transformArguments('src', 0, 1, {
// LIMIT: {
// offset: 0,
// count: 1
// }
// }),
// ['ZRANGEBYSCORE', 'src', '0', '1', 'LIMIT', '0', '1', 'WITHSCORES']
// );
// });
// });
testUtils.testWithClient('client.zRangeByScoreWithScores', async client => {
assert.deepEqual(
await client.zRangeByScoreWithScores('src', 0, 1),
[]
);
}, GLOBAL.SERVERS.OPEN);
});
// testUtils.testWithClient('client.zRangeByScoreWithScores', async client => {
// assert.deepEqual(
// await client.zRangeByScoreWithScores('src', 0, 1),
// []
// );
// }, GLOBAL.SERVERS.OPEN);
// });

View File

@@ -1,92 +1,92 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments, transformReply } from './ZRANGESTORE';
// import { strict as assert } from 'assert';
// import testUtils, { GLOBAL } from '../test-utils';
// import { transformArguments, transformReply } from './ZRANGESTORE';
describe('ZRANGESTORE', () => {
testUtils.isVersionGreaterThanHook([6, 2]);
// describe('ZRANGESTORE', () => {
// testUtils.isVersionGreaterThanHook([6, 2]);
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
transformArguments('dst', 'src', 0, 1),
['ZRANGESTORE', 'dst', 'src', '0', '1']
);
});
// describe('transformArguments', () => {
// it('simple', () => {
// assert.deepEqual(
// transformArguments('dst', 'src', 0, 1),
// ['ZRANGESTORE', 'dst', 'src', '0', '1']
// );
// });
it('with BYSCORE', () => {
assert.deepEqual(
transformArguments('dst', 'src', 0, 1, {
BY: 'SCORE'
}),
['ZRANGESTORE', 'dst', 'src', '0', '1', 'BYSCORE']
);
});
// it('with BYSCORE', () => {
// assert.deepEqual(
// transformArguments('dst', 'src', 0, 1, {
// BY: 'SCORE'
// }),
// ['ZRANGESTORE', 'dst', 'src', '0', '1', 'BYSCORE']
// );
// });
it('with BYLEX', () => {
assert.deepEqual(
transformArguments('dst', 'src', 0, 1, {
BY: 'LEX'
}),
['ZRANGESTORE', 'dst', 'src', '0', '1', 'BYLEX']
);
});
// it('with BYLEX', () => {
// assert.deepEqual(
// transformArguments('dst', 'src', 0, 1, {
// BY: 'LEX'
// }),
// ['ZRANGESTORE', 'dst', 'src', '0', '1', 'BYLEX']
// );
// });
it('with REV', () => {
assert.deepEqual(
transformArguments('dst', 'src', 0, 1, {
REV: true
}),
['ZRANGESTORE', 'dst', 'src', '0', '1', 'REV']
);
});
// it('with REV', () => {
// assert.deepEqual(
// transformArguments('dst', 'src', 0, 1, {
// REV: true
// }),
// ['ZRANGESTORE', 'dst', 'src', '0', '1', 'REV']
// );
// });
it('with LIMIT', () => {
assert.deepEqual(
transformArguments('dst', 'src', 0, 1, {
LIMIT: {
offset: 0,
count: 1
}
}),
['ZRANGESTORE', 'dst', 'src', '0', '1', 'LIMIT', '0', '1']
);
});
// it('with LIMIT', () => {
// assert.deepEqual(
// transformArguments('dst', 'src', 0, 1, {
// LIMIT: {
// offset: 0,
// count: 1
// }
// }),
// ['ZRANGESTORE', 'dst', 'src', '0', '1', 'LIMIT', '0', '1']
// );
// });
it('with BY & REV & LIMIT', () => {
assert.deepEqual(
transformArguments('dst', 'src', 0, 1, {
BY: 'SCORE',
REV: true,
LIMIT: {
offset: 0,
count: 1
},
WITHSCORES: true
}),
['ZRANGESTORE', 'dst', 'src', '0', '1', 'BYSCORE', 'REV', 'LIMIT', '0', '1', 'WITHSCORES']
);
});
});
// it('with BY & REV & LIMIT', () => {
// assert.deepEqual(
// transformArguments('dst', 'src', 0, 1, {
// BY: 'SCORE',
// REV: true,
// LIMIT: {
// offset: 0,
// count: 1
// },
// WITHSCORES: true
// }),
// ['ZRANGESTORE', 'dst', 'src', '0', '1', 'BYSCORE', 'REV', 'LIMIT', '0', '1', 'WITHSCORES']
// );
// });
// });
describe('transformReply', () => {
it('should throw TypeError when reply is not a number', () => {
assert.throws(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
() => (transformReply as any)([]),
TypeError
);
});
});
// describe('transformReply', () => {
// it('should throw TypeError when reply is not a number', () => {
// assert.throws(
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
// () => (transformReply as any)([]),
// TypeError
// );
// });
// });
testUtils.testWithClient('client.zRangeStore', async client => {
await client.zAdd('src', {
score: 0.5,
value: 'value'
});
// testUtils.testWithClient('client.zRangeStore', async client => {
// await client.zAdd('src', {
// score: 0.5,
// value: 'value'
// });
assert.equal(
await client.zRangeStore('dst', 'src', 0, 1),
1
);
}, GLOBAL.SERVERS.OPEN);
});
// assert.equal(
// await client.zRangeStore('dst', 'src', 0, 1),
// 1
// );
// }, GLOBAL.SERVERS.OPEN);
// });

View File

@@ -1,65 +1,65 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZRANGE_WITHSCORES';
// import { strict as assert } from 'assert';
// import testUtils, { GLOBAL } from '../test-utils';
// import { transformArguments } from './ZRANGE_WITHSCORES';
describe('ZRANGE WITHSCORES', () => {
describe('transformArguments', () => {
it('simple', () => {
assert.deepEqual(
transformArguments('src', 0, 1),
['ZRANGE', 'src', '0', '1', 'WITHSCORES']
);
});
// describe('ZRANGE WITHSCORES', () => {
// describe('transformArguments', () => {
// it('simple', () => {
// assert.deepEqual(
// transformArguments('src', 0, 1),
// ['ZRANGE', 'src', '0', '1', 'WITHSCORES']
// );
// });
it('with BY', () => {
assert.deepEqual(
transformArguments('src', 0, 1, {
BY: 'SCORE'
}),
['ZRANGE', 'src', '0', '1', 'BYSCORE', 'WITHSCORES']
);
});
// it('with BY', () => {
// assert.deepEqual(
// transformArguments('src', 0, 1, {
// BY: 'SCORE'
// }),
// ['ZRANGE', 'src', '0', '1', 'BYSCORE', 'WITHSCORES']
// );
// });
it('with REV', () => {
assert.deepEqual(
transformArguments('src', 0, 1, {
REV: true
}),
['ZRANGE', 'src', '0', '1', 'REV', 'WITHSCORES']
);
});
// it('with REV', () => {
// assert.deepEqual(
// transformArguments('src', 0, 1, {
// REV: true
// }),
// ['ZRANGE', 'src', '0', '1', 'REV', 'WITHSCORES']
// );
// });
it('with LIMIT', () => {
assert.deepEqual(
transformArguments('src', 0, 1, {
LIMIT: {
offset: 0,
count: 1
}
}),
['ZRANGE', 'src', '0', '1', 'LIMIT', '0', '1', 'WITHSCORES']
);
});
// it('with LIMIT', () => {
// assert.deepEqual(
// transformArguments('src', 0, 1, {
// LIMIT: {
// offset: 0,
// count: 1
// }
// }),
// ['ZRANGE', 'src', '0', '1', 'LIMIT', '0', '1', 'WITHSCORES']
// );
// });
it('with BY & REV & LIMIT', () => {
assert.deepEqual(
transformArguments('src', 0, 1, {
BY: 'SCORE',
REV: true,
LIMIT: {
offset: 0,
count: 1
}
}),
['ZRANGE', 'src', '0', '1', 'BYSCORE', 'REV', 'LIMIT', '0', '1', 'WITHSCORES']
);
});
});
// it('with BY & REV & LIMIT', () => {
// assert.deepEqual(
// transformArguments('src', 0, 1, {
// BY: 'SCORE',
// REV: true,
// LIMIT: {
// offset: 0,
// count: 1
// }
// }),
// ['ZRANGE', 'src', '0', '1', 'BYSCORE', 'REV', 'LIMIT', '0', '1', 'WITHSCORES']
// );
// });
// });
testUtils.testWithClient('client.zRangeWithScores', async client => {
assert.deepEqual(
await client.zRangeWithScores('src', 0, 1),
[]
);
}, GLOBAL.SERVERS.OPEN);
});
// testUtils.testWithClient('client.zRangeWithScores', async client => {
// assert.deepEqual(
// await client.zRangeWithScores('src', 0, 1),
// []
// );
// }, GLOBAL.SERVERS.OPEN);
// });

View File

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

View File

@@ -1,28 +1,31 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZREM';
import ZREM from './ZREM';
describe('ZREM', () => {
describe('transformArguments', () => {
it('string', () => {
assert.deepEqual(
transformArguments('key', 'member'),
ZREM.transformArguments('key', 'member'),
['ZREM', 'key', 'member']
);
});
it('array', () => {
assert.deepEqual(
transformArguments('key', ['1', '2']),
ZREM.transformArguments('key', ['1', '2']),
['ZREM', 'key', '1', '2']
);
});
});
testUtils.testWithClient('client.zRem', async client => {
testUtils.testAll('zRem', async client => {
assert.equal(
await client.zRem('key', 'member'),
0
);
}, GLOBAL.SERVERS.OPEN);
}, {
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 './ZREMRANGEBYLEX';
// import { strict as assert } from 'assert';
// import testUtils, { GLOBAL } from '../test-utils';
// import { transformArguments } from './ZREMRANGEBYLEX';
describe('ZREMRANGEBYLEX', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', '[a', '[b'),
['ZREMRANGEBYLEX', 'key', '[a', '[b']
);
});
// describe('ZREMRANGEBYLEX', () => {
// it('transformArguments', () => {
// assert.deepEqual(
// transformArguments('key', '[a', '[b'),
// ['ZREMRANGEBYLEX', 'key', '[a', '[b']
// );
// });
testUtils.testWithClient('client.zRemRangeByLex', async client => {
assert.equal(
await client.zRemRangeByLex('key', '[a', '[b'),
0
);
}, GLOBAL.SERVERS.OPEN);
});
// testUtils.testWithClient('client.zRemRangeByLex', async client => {
// assert.equal(
// await client.zRemRangeByLex('key', '[a', '[b'),
// 0
// );
// }, GLOBAL.SERVERS.OPEN);
// });

View File

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

View File

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

View File

@@ -1,19 +1,22 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZREVRANK';
import ZREVRANK from './ZREVRANK';
describe('ZREVRANK', () => {
it('transformArguments', () => {
assert.deepEqual(
transformArguments('key', 'member'),
ZREVRANK.transformArguments('key', 'member'),
['ZREVRANK', 'key', 'member']
);
});
testUtils.testWithClient('client.zRevRank', async client => {
testUtils.testAll('zRevRank', async client => {
assert.equal(
await client.zRevRank('key', 'member'),
null
);
}, GLOBAL.SERVERS.OPEN);
}, {
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, transformReply } from './ZSCAN';
import ZSCAN from './ZSCAN';
describe('ZSCAN', () => {
describe('transformArguments', () => {
it('cusror only', () => {
assert.deepEqual(
transformArguments('key', 0),
ZSCAN.transformArguments('key', 0),
['ZSCAN', 'key', '0']
);
});
it('with MATCH', () => {
assert.deepEqual(
transformArguments('key', 0, {
ZSCAN.transformArguments('key', 0, {
MATCH: 'pattern'
}),
['ZSCAN', 'key', '0', 'MATCH', 'pattern']
@@ -22,7 +22,7 @@ describe('ZSCAN', () => {
it('with COUNT', () => {
assert.deepEqual(
transformArguments('key', 0, {
ZSCAN.transformArguments('key', 0, {
COUNT: 1
}),
['ZSCAN', 'key', '0', 'COUNT', '1']
@@ -31,7 +31,7 @@ describe('ZSCAN', () => {
it('with MATCH & COUNT', () => {
assert.deepEqual(
transformArguments('key', 0, {
ZSCAN.transformArguments('key', 0, {
MATCH: 'pattern',
COUNT: 1
}),
@@ -40,32 +40,7 @@ describe('ZSCAN', () => {
});
});
describe('transformReply', () => {
it('without members', () => {
assert.deepEqual(
transformReply(['0', []]),
{
cursor: 0,
members: []
}
);
});
it('with members', () => {
assert.deepEqual(
transformReply(['0', ['member', '-inf']]),
{
cursor: 0,
members: [{
value: 'member',
score: -Infinity
}]
}
);
});
});
testUtils.testWithClient('client.zScan', async client => {
testUtils.testWithClient('zScan', async client => {
assert.deepEqual(
await client.zScan('key', 0),
{

View File

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

View File

@@ -1,48 +1,48 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZUNION';
// import { strict as assert } from 'assert';
// import testUtils, { GLOBAL } from '../test-utils';
// import { transformArguments } from './ZUNION';
describe('ZUNION', () => {
testUtils.isVersionGreaterThanHook([6, 2]);
// describe('ZUNION', () => {
// testUtils.isVersionGreaterThanHook([6, 2]);
describe('transformArguments', () => {
it('key (string)', () => {
assert.deepEqual(
transformArguments('key'),
['ZUNION', '1', 'key']
);
});
// describe('transformArguments', () => {
// it('key (string)', () => {
// assert.deepEqual(
// transformArguments('key'),
// ['ZUNION', '1', 'key']
// );
// });
it('keys (array)', () => {
assert.deepEqual(
transformArguments(['1', '2']),
['ZUNION', '2', '1', '2']
);
});
// it('keys (array)', () => {
// assert.deepEqual(
// transformArguments(['1', '2']),
// ['ZUNION', '2', '1', '2']
// );
// });
it('with WEIGHTS', () => {
assert.deepEqual(
transformArguments('key', {
WEIGHTS: [1]
}),
['ZUNION', '1', 'key', 'WEIGHTS', '1']
);
});
// it('with WEIGHTS', () => {
// assert.deepEqual(
// transformArguments('key', {
// WEIGHTS: [1]
// }),
// ['ZUNION', '1', 'key', 'WEIGHTS', '1']
// );
// });
it('with AGGREGATE', () => {
assert.deepEqual(
transformArguments('key', {
AGGREGATE: 'SUM'
}),
['ZUNION', '1', 'key', 'AGGREGATE', 'SUM']
);
});
});
// it('with AGGREGATE', () => {
// assert.deepEqual(
// transformArguments('key', {
// AGGREGATE: 'SUM'
// }),
// ['ZUNION', '1', 'key', 'AGGREGATE', 'SUM']
// );
// });
// });
testUtils.testWithClient('client.zUnion', async client => {
assert.deepEqual(
await client.zUnion('key'),
[]
);
}, GLOBAL.SERVERS.OPEN);
});
// testUtils.testWithClient('client.zUnion', async client => {
// assert.deepEqual(
// await client.zUnion('key'),
// []
// );
// }, GLOBAL.SERVERS.OPEN);
// });

View File

@@ -1,56 +1,56 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZUNIONSTORE';
// import { strict as assert } from 'assert';
// import testUtils, { GLOBAL } from '../test-utils';
// import { transformArguments } from './ZUNIONSTORE';
describe('ZUNIONSTORE', () => {
describe('transformArguments', () => {
it('key (string)', () => {
assert.deepEqual(
transformArguments('destination', 'key'),
['ZUNIONSTORE', 'destination', '1', 'key']
);
});
// describe('ZUNIONSTORE', () => {
// describe('transformArguments', () => {
// it('key (string)', () => {
// assert.deepEqual(
// transformArguments('destination', 'key'),
// ['ZUNIONSTORE', 'destination', '1', 'key']
// );
// });
it('keys (array)', () => {
assert.deepEqual(
transformArguments('destination', ['1', '2']),
['ZUNIONSTORE', 'destination', '2', '1', '2']
);
});
// it('keys (array)', () => {
// assert.deepEqual(
// transformArguments('destination', ['1', '2']),
// ['ZUNIONSTORE', 'destination', '2', '1', '2']
// );
// });
it('with WEIGHTS', () => {
assert.deepEqual(
transformArguments('destination', 'key', {
WEIGHTS: [1]
}),
['ZUNIONSTORE', 'destination', '1', 'key', 'WEIGHTS', '1']
);
});
// it('with WEIGHTS', () => {
// assert.deepEqual(
// transformArguments('destination', 'key', {
// WEIGHTS: [1]
// }),
// ['ZUNIONSTORE', 'destination', '1', 'key', 'WEIGHTS', '1']
// );
// });
it('with AGGREGATE', () => {
assert.deepEqual(
transformArguments('destination', 'key', {
AGGREGATE: 'SUM'
}),
['ZUNIONSTORE', 'destination', '1', 'key', 'AGGREGATE', 'SUM']
);
});
// it('with AGGREGATE', () => {
// assert.deepEqual(
// transformArguments('destination', 'key', {
// AGGREGATE: 'SUM'
// }),
// ['ZUNIONSTORE', 'destination', '1', 'key', 'AGGREGATE', 'SUM']
// );
// });
it('with WEIGHTS, AGGREGATE', () => {
assert.deepEqual(
transformArguments('destination', 'key', {
WEIGHTS: [1],
AGGREGATE: 'SUM'
}),
['ZUNIONSTORE', 'destination', '1', 'key', 'WEIGHTS', '1', 'AGGREGATE', 'SUM']
);
});
});
// it('with WEIGHTS, AGGREGATE', () => {
// assert.deepEqual(
// transformArguments('destination', 'key', {
// WEIGHTS: [1],
// AGGREGATE: 'SUM'
// }),
// ['ZUNIONSTORE', 'destination', '1', 'key', 'WEIGHTS', '1', 'AGGREGATE', 'SUM']
// );
// });
// });
testUtils.testWithClient('client.zUnionStore', async client => {
assert.equal(
await client.zUnionStore('destination', 'key'),
0
);
}, GLOBAL.SERVERS.OPEN);
});
// testUtils.testWithClient('client.zUnionStore', async client => {
// assert.equal(
// await client.zUnionStore('destination', 'key'),
// 0
// );
// }, GLOBAL.SERVERS.OPEN);
// });

View File

@@ -1,48 +1,48 @@
import { strict as assert } from 'assert';
import testUtils, { GLOBAL } from '../test-utils';
import { transformArguments } from './ZUNION_WITHSCORES';
// import { strict as assert } from 'assert';
// import testUtils, { GLOBAL } from '../test-utils';
// import { transformArguments } from './ZUNION_WITHSCORES';
describe('ZUNION WITHSCORES', () => {
testUtils.isVersionGreaterThanHook([6, 2]);
// describe('ZUNION WITHSCORES', () => {
// testUtils.isVersionGreaterThanHook([6, 2]);
describe('transformArguments', () => {
it('key (string)', () => {
assert.deepEqual(
transformArguments('key'),
['ZUNION', '1', 'key', 'WITHSCORES']
);
});
// describe('transformArguments', () => {
// it('key (string)', () => {
// assert.deepEqual(
// transformArguments('key'),
// ['ZUNION', '1', 'key', 'WITHSCORES']
// );
// });
it('keys (array)', () => {
assert.deepEqual(
transformArguments(['1', '2']),
['ZUNION', '2', '1', '2', 'WITHSCORES']
);
});
// it('keys (array)', () => {
// assert.deepEqual(
// transformArguments(['1', '2']),
// ['ZUNION', '2', '1', '2', 'WITHSCORES']
// );
// });
it('with WEIGHTS', () => {
assert.deepEqual(
transformArguments('key', {
WEIGHTS: [1]
}),
['ZUNION', '1', 'key', 'WEIGHTS', '1', 'WITHSCORES']
);
});
// it('with WEIGHTS', () => {
// assert.deepEqual(
// transformArguments('key', {
// WEIGHTS: [1]
// }),
// ['ZUNION', '1', 'key', 'WEIGHTS', '1', 'WITHSCORES']
// );
// });
it('with AGGREGATE', () => {
assert.deepEqual(
transformArguments('key', {
AGGREGATE: 'SUM'
}),
['ZUNION', '1', 'key', 'AGGREGATE', 'SUM', 'WITHSCORES']
);
});
});
// it('with AGGREGATE', () => {
// assert.deepEqual(
// transformArguments('key', {
// AGGREGATE: 'SUM'
// }),
// ['ZUNION', '1', 'key', 'AGGREGATE', 'SUM', 'WITHSCORES']
// );
// });
// });
testUtils.testWithClient('client.zUnionWithScores', async client => {
assert.deepEqual(
await client.zUnionWithScores('key'),
[]
);
}, GLOBAL.SERVERS.OPEN);
});
// testUtils.testWithClient('client.zUnionWithScores', async client => {
// assert.deepEqual(
// await client.zUnionWithScores('key'),
// []
// );
// }, GLOBAL.SERVERS.OPEN);
// });

View File

@@ -106,7 +106,28 @@ import SETRANGE from './SETRANGE';
import SMEMBERS from './SMEMBERS';
import SSCAN from './SSCAN';
import STRLEN from './STRLEN';
import ZADD from './ZADD';
import ZCARD from './ZCARD';
import ZCOUNT from './ZCOUNT';
import ZDIFF_WITHSCORES from './ZDIFF_WITHSCORES';
import ZDIFF from './ZDIFF';
import ZDIFFSTORE from './ZDIFFSTORE';
import ZINCRBY from './ZINCRBY';
import ZINTER_WITHSCORES from './ZINTER_WITHSCORES';
import ZINTER from './ZINTER';
import ZINTERCARD from './ZINTERCARD';
import ZINTERSTORE from './ZINTERSTORE';
import ZLEXCOUNT from './ZLEXCOUNT';
import ZMSCORE from './ZMSCORE';
import ZRANDMEMBER_COUNT_WITHSCORES from './ZRANDMEMBER_COUNT_WITHSCORES';
import ZRANDMEMBER_COUNT from './ZRANDMEMBER_COUNT';
import ZRANDMEMBER from './ZRANDMEMBER';
import ZRANGE from './ZRANGE';
import ZRANK from './ZRANK';
import ZREM from './ZREM';
import ZREVRANK from './ZREVRANK';
import ZSCAN from './ZSCAN';
import ZSCORE from './ZSCORE';
import { Command } from '../RESP/types';
export default {
@@ -327,6 +348,48 @@ export default {
sScan: SSCAN,
STRLEN,
strLen: STRLEN,
ZADD,
zAdd: ZADD,
ZCARD,
zCard: ZCARD,
ZCOUNT,
zCount: ZCOUNT,
ZDIFF_WITHSCORES,
zDiffWithScores: ZDIFF_WITHSCORES,
ZDIFF,
zDiff: ZDIFF,
ZDIFFSTORE,
zDiffStore: ZDIFFSTORE,
ZINCRBY,
zIncrBy: ZINCRBY,
ZINTER_WITHSCORES,
zInterWithScores: ZINTER_WITHSCORES,
ZINTER,
zInter: ZINTER,
ZINTERCARD,
zInterCard: ZINTERCARD,
ZINTERSTORE,
zInterStore: ZINTERSTORE,
ZLEXCOUNT,
zLexCount: ZLEXCOUNT,
ZMSCORE,
zmScore: ZMSCORE,
ZRANDMEMBER_COUNT_WITHSCORES,
zRandMemberCountWithScores: ZRANDMEMBER_COUNT_WITHSCORES,
ZRANDMEMBER_COUNT,
zRandMemberCount: ZRANDMEMBER_COUNT,
ZRANDMEMBER,
zRandMember: ZRANDMEMBER,
ZRANGE,
zRange: ZRANGE,
ZRANK,
zRank: ZRANK,
ZREM,
zRem: ZREM,
ZREVRANK,
zRevRank: ZREVRANK,
ZSCAN,
zScan: ZSCAN
zScan: ZSCAN,
ZSCORE,
zScore: ZSCORE
} as const satisfies Record<string, Command>;