You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-07 13:22:56 +03:00
wip
This commit is contained in:
@@ -1,27 +1,27 @@
|
|||||||
import { strict as assert } from 'assert';
|
// import { strict as assert } from 'assert';
|
||||||
import { transformArguments } from './SHUTDOWN';
|
// import { transformArguments } from './SHUTDOWN';
|
||||||
|
|
||||||
describe('SHUTDOWN', () => {
|
// describe('SHUTDOWN', () => {
|
||||||
describe('transformArguments', () => {
|
// describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
// it('simple', () => {
|
||||||
assert.deepEqual(
|
// assert.deepEqual(
|
||||||
transformArguments(),
|
// transformArguments(),
|
||||||
['SHUTDOWN']
|
// ['SHUTDOWN']
|
||||||
);
|
// );
|
||||||
});
|
// });
|
||||||
|
|
||||||
it('NOSAVE', () => {
|
// it('NOSAVE', () => {
|
||||||
assert.deepEqual(
|
// assert.deepEqual(
|
||||||
transformArguments('NOSAVE'),
|
// transformArguments('NOSAVE'),
|
||||||
['SHUTDOWN', 'NOSAVE']
|
// ['SHUTDOWN', 'NOSAVE']
|
||||||
);
|
// );
|
||||||
});
|
// });
|
||||||
|
|
||||||
it('SAVE', () => {
|
// it('SAVE', () => {
|
||||||
assert.deepEqual(
|
// assert.deepEqual(
|
||||||
transformArguments('SAVE'),
|
// transformArguments('SAVE'),
|
||||||
['SHUTDOWN', 'SAVE']
|
// ['SHUTDOWN', 'SAVE']
|
||||||
);
|
// );
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
|
@@ -1,11 +1,11 @@
|
|||||||
export function transformArguments(mode?: 'NOSAVE' | 'SAVE'): Array<string> {
|
// export function transformArguments(mode?: 'NOSAVE' | 'SAVE'): Array<string> {
|
||||||
const args = ['SHUTDOWN'];
|
// const args = ['SHUTDOWN'];
|
||||||
|
|
||||||
if (mode) {
|
// if (mode) {
|
||||||
args.push(mode);
|
// args.push(mode);
|
||||||
}
|
// }
|
||||||
|
|
||||||
return args;
|
// return args;
|
||||||
}
|
// }
|
||||||
|
|
||||||
export declare function transformReply(): void;
|
// export declare function transformReply(): void;
|
||||||
|
@@ -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 './SINTER';
|
import SINTER from './SINTER';
|
||||||
|
|
||||||
describe('SINTER', () => {
|
describe('SINTER', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('string', () => {
|
it('string', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key'),
|
SINTER.transformArguments('key'),
|
||||||
['SINTER', 'key']
|
['SINTER', 'key']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('array', () => {
|
it('array', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments(['1', '2']),
|
SINTER.transformArguments(['1', '2']),
|
||||||
['SINTER', '1', '2']
|
['SINTER', '1', '2']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.sInter', async client => {
|
testUtils.testAll('sInter', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.sInter('key'),
|
await client.sInter('key'),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -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 './SINTERCARD';
|
import SINTERCARD from './SINTERCARD';
|
||||||
|
|
||||||
describe('SINTERCARD', () => {
|
describe('SINTERCARD', () => {
|
||||||
testUtils.isVersionGreaterThanHook([7]);
|
testUtils.isVersionGreaterThanHook([7]);
|
||||||
@@ -8,23 +8,35 @@ describe('SINTERCARD', () => {
|
|||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments(['1', '2']),
|
SINTERCARD.transformArguments(['1', '2']),
|
||||||
['SINTERCARD', '2', '1', '2']
|
['SINTERCARD', '2', '1', '2']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with limit', () => {
|
it('with limit (backwards compatibility)', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments(['1', '2'], 1),
|
SINTERCARD.transformArguments(['1', '2'], 1),
|
||||||
|
['SINTERCARD', '2', '1', '2', 'LIMIT', '1']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('with LIMIT', () => {
|
||||||
|
assert.deepEqual(
|
||||||
|
SINTERCARD.transformArguments(['1', '2'], {
|
||||||
|
LIMIT: 1
|
||||||
|
}),
|
||||||
['SINTERCARD', '2', '1', '2', 'LIMIT', '1']
|
['SINTERCARD', '2', '1', '2', 'LIMIT', '1']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.sInterCard', async client => {
|
testUtils.testAll('sInterCard', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.sInterCard('key'),
|
await client.sInterCard('key'),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { RedisArgument, NumberReply, Command } from '../RESP/types';
|
import { RedisArgument, NumberReply, Command } from '../RESP/types';
|
||||||
import { pushVariadicArguments } from './generic-transformers';
|
import { pushVariadicArgument } from './generic-transformers';
|
||||||
|
|
||||||
export interface SInterCardOptions {
|
export interface SInterCardOptions {
|
||||||
LIMIT?: number;
|
LIMIT?: number;
|
||||||
@@ -12,7 +12,7 @@ export default {
|
|||||||
keys: Array<RedisArgument> | RedisArgument,
|
keys: Array<RedisArgument> | RedisArgument,
|
||||||
options?: SInterCardOptions | number // `number` for backwards compatibility
|
options?: SInterCardOptions | number // `number` for backwards compatibility
|
||||||
) {
|
) {
|
||||||
const args = pushVariadicArguments(['SINTERCARD'], keys);
|
const args = pushVariadicArgument(['SINTERCARD'], keys);
|
||||||
|
|
||||||
if (typeof options === 'number') { // backwards compatibility
|
if (typeof options === 'number') { // backwards compatibility
|
||||||
args.push('LIMIT', options.toString());
|
args.push('LIMIT', options.toString());
|
||||||
|
@@ -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 './SINTERSTORE';
|
import SINTERSTORE from './SINTERSTORE';
|
||||||
|
|
||||||
describe('SINTERSTORE', () => {
|
describe('SINTERSTORE', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('string', () => {
|
it('string', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('destination', 'key'),
|
SINTERSTORE.transformArguments('destination', 'key'),
|
||||||
['SINTERSTORE', 'destination', 'key']
|
['SINTERSTORE', 'destination', 'key']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('array', () => {
|
it('array', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('destination', ['1', '2']),
|
SINTERSTORE.transformArguments('destination', ['1', '2']),
|
||||||
['SINTERSTORE', 'destination', '1', '2']
|
['SINTERSTORE', 'destination', '1', '2']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.sInterStore', async client => {
|
testUtils.testAll('sInterStore', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.sInterStore('destination', 'key'),
|
await client.sInterStore('{tag}destination', '{tag}key'),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -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 './SISMEMBER';
|
import SISMEMBER from './SISMEMBER';
|
||||||
|
|
||||||
describe('SISMEMBER', () => {
|
describe('SISMEMBER', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', 'member'),
|
SISMEMBER.transformArguments('key', 'member'),
|
||||||
['SISMEMBER', 'key', 'member']
|
['SISMEMBER', 'key', 'member']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.sIsMember', async client => {
|
testUtils.testAll('sIsMember', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.sIsMember('key', 'member'),
|
await client.sIsMember('key', 'member'),
|
||||||
false
|
0
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -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 './SMEMBERS';
|
import SMEMBERS from './SMEMBERS';
|
||||||
|
|
||||||
describe('SMEMBERS', () => {
|
describe('SMEMBERS', () => {
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key'),
|
SMEMBERS.transformArguments('key'),
|
||||||
['SMEMBERS', 'key']
|
['SMEMBERS', 'key']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.sMembers', async client => {
|
testUtils.testAll('sMembers', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.sMembers('key'),
|
await client.sMembers('key'),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -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 './SMISMEMBER';
|
import SMISMEMBER from './SMISMEMBER';
|
||||||
|
|
||||||
describe('SMISMEMBER', () => {
|
describe('SMISMEMBER', () => {
|
||||||
testUtils.isVersionGreaterThanHook([6, 2]);
|
testUtils.isVersionGreaterThanHook([6, 2]);
|
||||||
|
|
||||||
it('transformArguments', () => {
|
it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', ['1', '2']),
|
SMISMEMBER.transformArguments('key', ['1', '2']),
|
||||||
['SMISMEMBER', 'key', '1', '2']
|
['SMISMEMBER', 'key', '1', '2']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.smIsMember', async client => {
|
testUtils.testAll('smIsMember', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.smIsMember('key', ['1', '2']),
|
await client.smIsMember('key', ['1', '2']),
|
||||||
[false, false]
|
[0, 0]
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,19 +1,19 @@
|
|||||||
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 './SMOVE';
|
// import { transformArguments } from './SMOVE';
|
||||||
|
|
||||||
describe('SMOVE', () => {
|
// describe('SMOVE', () => {
|
||||||
it('transformArguments', () => {
|
// it('transformArguments', () => {
|
||||||
assert.deepEqual(
|
// assert.deepEqual(
|
||||||
transformArguments('source', 'destination', 'member'),
|
// transformArguments('source', 'destination', 'member'),
|
||||||
['SMOVE', 'source', 'destination', 'member']
|
// ['SMOVE', 'source', 'destination', 'member']
|
||||||
);
|
// );
|
||||||
});
|
// });
|
||||||
|
|
||||||
testUtils.testWithClient('client.sMove', async client => {
|
// testUtils.testWithClient('client.sMove', async client => {
|
||||||
assert.equal(
|
// assert.equal(
|
||||||
await client.sMove('source', 'destination', 'member'),
|
// await client.sMove('source', 'destination', 'member'),
|
||||||
false
|
// false
|
||||||
);
|
// );
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
// }, GLOBAL.SERVERS.OPEN);
|
||||||
});
|
// });
|
||||||
|
@@ -1,19 +1,19 @@
|
|||||||
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 './SORT';
|
import SORT from './SORT';
|
||||||
|
|
||||||
describe('SORT', () => {
|
describe('SORT', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key'),
|
SORT.transformArguments('key'),
|
||||||
['SORT', 'key']
|
['SORT', 'key']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with BY', () => {
|
it('with BY', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', {
|
SORT.transformArguments('key', {
|
||||||
BY: 'pattern'
|
BY: 'pattern'
|
||||||
}),
|
}),
|
||||||
['SORT', 'key', 'BY', 'pattern']
|
['SORT', 'key', 'BY', 'pattern']
|
||||||
@@ -22,7 +22,7 @@ describe('SORT', () => {
|
|||||||
|
|
||||||
it('with LIMIT', () => {
|
it('with LIMIT', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', {
|
SORT.transformArguments('key', {
|
||||||
LIMIT: {
|
LIMIT: {
|
||||||
offset: 0,
|
offset: 0,
|
||||||
count: 1
|
count: 1
|
||||||
@@ -35,7 +35,7 @@ describe('SORT', () => {
|
|||||||
describe('with GET', () => {
|
describe('with GET', () => {
|
||||||
it('string', () => {
|
it('string', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', {
|
SORT.transformArguments('key', {
|
||||||
GET: 'pattern'
|
GET: 'pattern'
|
||||||
}),
|
}),
|
||||||
['SORT', 'key', 'GET', 'pattern']
|
['SORT', 'key', 'GET', 'pattern']
|
||||||
@@ -44,7 +44,7 @@ describe('SORT', () => {
|
|||||||
|
|
||||||
it('array', () => {
|
it('array', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', {
|
SORT.transformArguments('key', {
|
||||||
GET: ['1', '2']
|
GET: ['1', '2']
|
||||||
}),
|
}),
|
||||||
['SORT', 'key', 'GET', '1', 'GET', '2']
|
['SORT', 'key', 'GET', '1', 'GET', '2']
|
||||||
@@ -54,7 +54,7 @@ describe('SORT', () => {
|
|||||||
|
|
||||||
it('with DIRECTION', () => {
|
it('with DIRECTION', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', {
|
SORT.transformArguments('key', {
|
||||||
DIRECTION: 'ASC'
|
DIRECTION: 'ASC'
|
||||||
}),
|
}),
|
||||||
['SORT', 'key', 'ASC']
|
['SORT', 'key', 'ASC']
|
||||||
@@ -63,7 +63,7 @@ describe('SORT', () => {
|
|||||||
|
|
||||||
it('with ALPHA', () => {
|
it('with ALPHA', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', {
|
SORT.transformArguments('key', {
|
||||||
ALPHA: true
|
ALPHA: true
|
||||||
}),
|
}),
|
||||||
['SORT', 'key', 'ALPHA']
|
['SORT', 'key', 'ALPHA']
|
||||||
@@ -72,7 +72,7 @@ describe('SORT', () => {
|
|||||||
|
|
||||||
it('with BY, LIMIT, GET, DIRECTION, ALPHA', () => {
|
it('with BY, LIMIT, GET, DIRECTION, ALPHA', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', {
|
SORT.transformArguments('key', {
|
||||||
BY: 'pattern',
|
BY: 'pattern',
|
||||||
LIMIT: {
|
LIMIT: {
|
||||||
offset: 0,
|
offset: 0,
|
||||||
@@ -87,10 +87,13 @@ describe('SORT', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.sort', async client => {
|
testUtils.testAll('sort', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.sort('key'),
|
await client.sort('key'),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,21 +1,22 @@
|
|||||||
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '../RESP/types';
|
import { RedisArgument, ArrayReply, BlobStringReply, Command } from '../RESP/types';
|
||||||
|
|
||||||
export interface SortOptions {
|
export interface SortOptions {
|
||||||
BY?: string;
|
BY?: RedisArgument;
|
||||||
LIMIT?: {
|
LIMIT?: {
|
||||||
offset: number;
|
offset: number;
|
||||||
count: number;
|
count: number;
|
||||||
},
|
};
|
||||||
GET?: string | Array<string>;
|
GET?: RedisArgument | Array<RedisArgument>;
|
||||||
DIRECTION?: 'ASC' | 'DESC';
|
DIRECTION?: 'ASC' | 'DESC';
|
||||||
ALPHA?: true;
|
ALPHA?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function transformSortArguments(
|
export function transformSortArguments(
|
||||||
command: RedisArgument,
|
command: RedisArgument,
|
||||||
|
key: RedisArgument,
|
||||||
options?: SortOptions
|
options?: SortOptions
|
||||||
) {
|
) {
|
||||||
const args = [command];
|
const args: Array<RedisArgument> = [command, key];
|
||||||
|
|
||||||
if (options?.BY) {
|
if (options?.BY) {
|
||||||
args.push('BY', options.BY);
|
args.push('BY', options.BY);
|
||||||
@@ -30,12 +31,12 @@ export function transformSortArguments(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (options?.GET) {
|
if (options?.GET) {
|
||||||
if (typeof options.GET === 'string') {
|
if (Array.isArray(options.GET)) {
|
||||||
args.push('GET', options.GET);
|
|
||||||
} else {
|
|
||||||
for (const pattern of options.GET) {
|
for (const pattern of options.GET) {
|
||||||
args.push('GET', pattern);
|
args.push('GET', pattern);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
args.push('GET', options.GET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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 './SORT_RO';
|
import SORT_RO from './SORT_RO';
|
||||||
|
|
||||||
describe('SORT_RO', () => {
|
describe('SORT_RO', () => {
|
||||||
testUtils.isVersionGreaterThanHook([7]);
|
testUtils.isVersionGreaterThanHook([7]);
|
||||||
@@ -8,14 +8,14 @@ describe('SORT_RO', () => {
|
|||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key'),
|
SORT_RO.transformArguments('key'),
|
||||||
['SORT_RO', 'key']
|
['SORT_RO', 'key']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with BY', () => {
|
it('with BY', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', {
|
SORT_RO.transformArguments('key', {
|
||||||
BY: 'pattern'
|
BY: 'pattern'
|
||||||
}),
|
}),
|
||||||
['SORT_RO', 'key', 'BY', 'pattern']
|
['SORT_RO', 'key', 'BY', 'pattern']
|
||||||
@@ -24,7 +24,7 @@ describe('SORT_RO', () => {
|
|||||||
|
|
||||||
it('with LIMIT', () => {
|
it('with LIMIT', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', {
|
SORT_RO.transformArguments('key', {
|
||||||
LIMIT: {
|
LIMIT: {
|
||||||
offset: 0,
|
offset: 0,
|
||||||
count: 1
|
count: 1
|
||||||
@@ -37,7 +37,7 @@ describe('SORT_RO', () => {
|
|||||||
describe('with GET', () => {
|
describe('with GET', () => {
|
||||||
it('string', () => {
|
it('string', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', {
|
SORT_RO.transformArguments('key', {
|
||||||
GET: 'pattern'
|
GET: 'pattern'
|
||||||
}),
|
}),
|
||||||
['SORT_RO', 'key', 'GET', 'pattern']
|
['SORT_RO', 'key', 'GET', 'pattern']
|
||||||
@@ -46,7 +46,7 @@ describe('SORT_RO', () => {
|
|||||||
|
|
||||||
it('array', () => {
|
it('array', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', {
|
SORT_RO.transformArguments('key', {
|
||||||
GET: ['1', '2']
|
GET: ['1', '2']
|
||||||
}),
|
}),
|
||||||
['SORT_RO', 'key', 'GET', '1', 'GET', '2']
|
['SORT_RO', 'key', 'GET', '1', 'GET', '2']
|
||||||
@@ -56,7 +56,7 @@ describe('SORT_RO', () => {
|
|||||||
|
|
||||||
it('with DIRECTION', () => {
|
it('with DIRECTION', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', {
|
SORT_RO.transformArguments('key', {
|
||||||
DIRECTION: 'ASC'
|
DIRECTION: 'ASC'
|
||||||
}),
|
}),
|
||||||
['SORT_RO', 'key', 'ASC']
|
['SORT_RO', 'key', 'ASC']
|
||||||
@@ -65,7 +65,7 @@ describe('SORT_RO', () => {
|
|||||||
|
|
||||||
it('with ALPHA', () => {
|
it('with ALPHA', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', {
|
SORT_RO.transformArguments('key', {
|
||||||
ALPHA: true
|
ALPHA: true
|
||||||
}),
|
}),
|
||||||
['SORT_RO', 'key', 'ALPHA']
|
['SORT_RO', 'key', 'ALPHA']
|
||||||
@@ -74,7 +74,7 @@ describe('SORT_RO', () => {
|
|||||||
|
|
||||||
it('with BY, LIMIT, GET, DIRECTION, ALPHA', () => {
|
it('with BY, LIMIT, GET, DIRECTION, ALPHA', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('key', {
|
SORT_RO.transformArguments('key', {
|
||||||
BY: 'pattern',
|
BY: 'pattern',
|
||||||
LIMIT: {
|
LIMIT: {
|
||||||
offset: 0,
|
offset: 0,
|
||||||
@@ -89,10 +89,13 @@ describe('SORT_RO', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.sortRo', async client => {
|
testUtils.testAll('client.sortRo', async client => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
await client.sortRo('key'),
|
await client.sortRo('key'),
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,19 +1,19 @@
|
|||||||
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 './SORT_STORE';
|
import SORT_STORE from './SORT_STORE';
|
||||||
|
|
||||||
describe('SORT STORE', () => {
|
describe('SORT STORE', () => {
|
||||||
describe('transformArguments', () => {
|
describe('transformArguments', () => {
|
||||||
it('simple', () => {
|
it('simple', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('source', 'destination'),
|
SORT_STORE.transformArguments('source', 'destination'),
|
||||||
['SORT', 'source', 'STORE', 'destination']
|
['SORT', 'source', 'STORE', 'destination']
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('with BY', () => {
|
it('with BY', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('source', 'destination', {
|
SORT_STORE.transformArguments('source', 'destination', {
|
||||||
BY: 'pattern'
|
BY: 'pattern'
|
||||||
}),
|
}),
|
||||||
['SORT', 'source', 'BY', 'pattern', 'STORE', 'destination']
|
['SORT', 'source', 'BY', 'pattern', 'STORE', 'destination']
|
||||||
@@ -22,7 +22,7 @@ describe('SORT STORE', () => {
|
|||||||
|
|
||||||
it('with LIMIT', () => {
|
it('with LIMIT', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('source', 'destination', {
|
SORT_STORE.transformArguments('source', 'destination', {
|
||||||
LIMIT: {
|
LIMIT: {
|
||||||
offset: 0,
|
offset: 0,
|
||||||
count: 1
|
count: 1
|
||||||
@@ -35,7 +35,7 @@ describe('SORT STORE', () => {
|
|||||||
describe('with GET', () => {
|
describe('with GET', () => {
|
||||||
it('string', () => {
|
it('string', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('source', 'destination', {
|
SORT_STORE.transformArguments('source', 'destination', {
|
||||||
GET: 'pattern'
|
GET: 'pattern'
|
||||||
}),
|
}),
|
||||||
['SORT', 'source', 'GET', 'pattern', 'STORE', 'destination']
|
['SORT', 'source', 'GET', 'pattern', 'STORE', 'destination']
|
||||||
@@ -44,7 +44,7 @@ describe('SORT STORE', () => {
|
|||||||
|
|
||||||
it('array', () => {
|
it('array', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('source', 'destination', {
|
SORT_STORE.transformArguments('source', 'destination', {
|
||||||
GET: ['1', '2']
|
GET: ['1', '2']
|
||||||
}),
|
}),
|
||||||
['SORT', 'source', 'GET', '1', 'GET', '2', 'STORE', 'destination']
|
['SORT', 'source', 'GET', '1', 'GET', '2', 'STORE', 'destination']
|
||||||
@@ -54,7 +54,7 @@ describe('SORT STORE', () => {
|
|||||||
|
|
||||||
it('with DIRECTION', () => {
|
it('with DIRECTION', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('source', 'destination', {
|
SORT_STORE.transformArguments('source', 'destination', {
|
||||||
DIRECTION: 'ASC'
|
DIRECTION: 'ASC'
|
||||||
}),
|
}),
|
||||||
['SORT', 'source', 'ASC', 'STORE', 'destination']
|
['SORT', 'source', 'ASC', 'STORE', 'destination']
|
||||||
@@ -63,7 +63,7 @@ describe('SORT STORE', () => {
|
|||||||
|
|
||||||
it('with ALPHA', () => {
|
it('with ALPHA', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('source', 'destination', {
|
SORT_STORE.transformArguments('source', 'destination', {
|
||||||
ALPHA: true
|
ALPHA: true
|
||||||
}),
|
}),
|
||||||
['SORT', 'source', 'ALPHA', 'STORE', 'destination']
|
['SORT', 'source', 'ALPHA', 'STORE', 'destination']
|
||||||
@@ -72,7 +72,7 @@ describe('SORT STORE', () => {
|
|||||||
|
|
||||||
it('with BY, LIMIT, GET, DIRECTION, ALPHA', () => {
|
it('with BY, LIMIT, GET, DIRECTION, ALPHA', () => {
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
transformArguments('source', 'destination', {
|
SORT_STORE.transformArguments('source', 'destination', {
|
||||||
BY: 'pattern',
|
BY: 'pattern',
|
||||||
LIMIT: {
|
LIMIT: {
|
||||||
offset: 0,
|
offset: 0,
|
||||||
@@ -87,10 +87,13 @@ describe('SORT STORE', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
testUtils.testWithClient('client.sortStore', async client => {
|
testUtils.testAll('sortStore', async client => {
|
||||||
assert.equal(
|
assert.equal(
|
||||||
await client.sortStore('source', 'destination'),
|
await client.sortStore('{tag}source', '{tag}destination'),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}, GLOBAL.SERVERS.OPEN);
|
}, {
|
||||||
|
client: GLOBAL.SERVERS.OPEN,
|
||||||
|
cluster: GLOBAL.CLUSTERS.OPEN
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { RedisArgument, NumberReply, Command } from '../RESP/types';
|
import { RedisArgument, NumberReply, Command } from '../RESP/types';
|
||||||
import { SortOptions, transformSortArguments } from './SORT';
|
import SORT, { SortOptions } from './SORT';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
FIRST_KEY_INDEX: 1,
|
FIRST_KEY_INDEX: 1,
|
||||||
@@ -9,7 +9,7 @@ export default {
|
|||||||
destination: RedisArgument,
|
destination: RedisArgument,
|
||||||
options?: SortOptions
|
options?: SortOptions
|
||||||
) {
|
) {
|
||||||
const args = transformSortArguments(source, options);
|
const args = SORT.transformArguments(source, options);
|
||||||
args.push('STORE', destination);
|
args.push('STORE', destination);
|
||||||
return args;
|
return args;
|
||||||
},
|
},
|
||||||
|
@@ -103,7 +103,15 @@ import SET from './SET';
|
|||||||
import SETEX from './SETEX';
|
import SETEX from './SETEX';
|
||||||
import SETNX from './SETNX';
|
import SETNX from './SETNX';
|
||||||
import SETRANGE from './SETRANGE';
|
import SETRANGE from './SETRANGE';
|
||||||
|
import SINTER from './SINTER';
|
||||||
|
import SINTERCARD from './SINTERCARD';
|
||||||
|
import SINTERSTORE from './SINTERSTORE';
|
||||||
|
import SISMEMBER from './SISMEMBER';
|
||||||
import SMEMBERS from './SMEMBERS';
|
import SMEMBERS from './SMEMBERS';
|
||||||
|
import SMISMEMBER from './SMISMEMBER';
|
||||||
|
import SORT_RO from './SORT_RO';
|
||||||
|
import SORT_STORE from './SORT_STORE';
|
||||||
|
import SORT from './SORT';
|
||||||
import SPUBLISH from './SPUBLISH';
|
import SPUBLISH from './SPUBLISH';
|
||||||
import SRANDMEMBER_COUNT from './SRANDMEMBER_COUNT';
|
import SRANDMEMBER_COUNT from './SRANDMEMBER_COUNT';
|
||||||
import SRANDMEMBER from './SRANDMEMBER';
|
import SRANDMEMBER from './SRANDMEMBER';
|
||||||
@@ -352,10 +360,24 @@ export default {
|
|||||||
setEx: SETEX,
|
setEx: SETEX,
|
||||||
SETNX,
|
SETNX,
|
||||||
setNx: SETNX,
|
setNx: SETNX,
|
||||||
SETRANGE,
|
SINTER,
|
||||||
setRange: SETRANGE,
|
sInter: SINTER,
|
||||||
|
SINTERCARD,
|
||||||
|
sInterCard: SINTERCARD,
|
||||||
|
SINTERSTORE,
|
||||||
|
sInterStore: SINTERSTORE,
|
||||||
|
SISMEMBER,
|
||||||
|
sIsMember: SISMEMBER,
|
||||||
SMEMBERS,
|
SMEMBERS,
|
||||||
sMembers: SMEMBERS,
|
sMembers: SMEMBERS,
|
||||||
|
SMISMEMBER,
|
||||||
|
smIsMember: SMISMEMBER,
|
||||||
|
SORT_RO,
|
||||||
|
sortRo: SORT_RO,
|
||||||
|
SORT_STORE,
|
||||||
|
sortStore: SORT_STORE,
|
||||||
|
SORT,
|
||||||
|
sort: SORT,
|
||||||
SPUBLISH,
|
SPUBLISH,
|
||||||
sPublish: SPUBLISH,
|
sPublish: SPUBLISH,
|
||||||
SRANDMEMBER_COUNT,
|
SRANDMEMBER_COUNT,
|
||||||
|
Reference in New Issue
Block a user