From a8679f37eca6d5af29a04485c6089729b33e8876 Mon Sep 17 00:00:00 2001 From: dovi Date: Wed, 3 May 2023 18:10:04 -0400 Subject: [PATCH 1/7] clean code --- packages/client/lib/commands/LRANGE.spec.ts | 1 - packages/client/lib/commands/LREM.spec.ts | 1 - todo.md | 1 - 3 files changed, 3 deletions(-) diff --git a/packages/client/lib/commands/LRANGE.spec.ts b/packages/client/lib/commands/LRANGE.spec.ts index 12f0c8f7b9..a5a70db6ee 100644 --- a/packages/client/lib/commands/LRANGE.spec.ts +++ b/packages/client/lib/commands/LRANGE.spec.ts @@ -1,4 +1,3 @@ - import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; import LRANGE from './LRANGE'; diff --git a/packages/client/lib/commands/LREM.spec.ts b/packages/client/lib/commands/LREM.spec.ts index bbc3f6096e..40aff2e8af 100644 --- a/packages/client/lib/commands/LREM.spec.ts +++ b/packages/client/lib/commands/LREM.spec.ts @@ -1,4 +1,3 @@ - import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; import LREM from './LREM'; diff --git a/todo.md b/todo.md index 53d90d83ea..c969748d18 100644 --- a/todo.md +++ b/todo.md @@ -11,7 +11,6 @@ # waiting List categoreis -- Hash - List - Set - Bitmap From 65c691fd756b72d34cf3c8331e584e9cec90f879 Mon Sep 17 00:00:00 2001 From: dovi Date: Wed, 3 May 2023 18:23:45 -0400 Subject: [PATCH 2/7] fix SMOVE --- docs/v4-to-v5.md | 1 + packages/client/lib/commands/SMOVE.spec.ts | 37 ++++++++++++---------- packages/client/lib/commands/SMOVE.ts | 25 ++++++++------- packages/client/lib/commands/index.ts | 3 ++ todo.md | 1 - 5 files changed, 37 insertions(+), 30 deletions(-) diff --git a/docs/v4-to-v5.md b/docs/v4-to-v5.md index 481bd95c69..29d23f4929 100644 --- a/docs/v4-to-v5.md +++ b/docs/v4-to-v5.md @@ -85,6 +85,7 @@ Some command arguments/replies have changed to align more closely to data types - `SCRIPT EXISTS`: `Array` -> `Array` [^boolean-to-number] - `SISMEMBER`: `boolean` -> `number` [^boolean-to-number] - `SMISMEMBER`: `Array` -> `Array` [^boolean-to-number] +- `SMOVE`: `boolean` -> `number` [^boolean-to-number] [^enum-to-constants]: TODO diff --git a/packages/client/lib/commands/SMOVE.spec.ts b/packages/client/lib/commands/SMOVE.spec.ts index d3a9ca6eda..60007ceffd 100644 --- a/packages/client/lib/commands/SMOVE.spec.ts +++ b/packages/client/lib/commands/SMOVE.spec.ts @@ -1,19 +1,22 @@ -// import { strict as assert } from 'assert'; -// import testUtils, { GLOBAL } from '../test-utils'; -// import { transformArguments } from './SMOVE'; +import { strict as assert } from 'assert'; +import testUtils, { GLOBAL } from '../test-utils'; +import SMOVE from './SMOVE'; -// describe('SMOVE', () => { -// it('transformArguments', () => { -// assert.deepEqual( -// transformArguments('source', 'destination', 'member'), -// ['SMOVE', 'source', 'destination', 'member'] -// ); -// }); +describe('SMOVE', () => { + it('transformArguments', () => { + assert.deepEqual( + SMOVE.transformArguments('source', 'destination', 'member'), + ['SMOVE', 'source', 'destination', 'member'] + ); + }); -// testUtils.testWithClient('client.sMove', async client => { -// assert.equal( -// await client.sMove('source', 'destination', 'member'), -// false -// ); -// }, GLOBAL.SERVERS.OPEN); -// }); + testUtils.testAll('sMove', async client => { + assert.equal( + await client.sMove('{tag}source', '{tag}destination', 'member'), + 0 + ); + }, { + client: GLOBAL.SERVERS.OPEN, + cluster: GLOBAL.CLUSTERS.OPEN + }); +}); diff --git a/packages/client/lib/commands/SMOVE.ts b/packages/client/lib/commands/SMOVE.ts index d6759c6212..183b363fb9 100644 --- a/packages/client/lib/commands/SMOVE.ts +++ b/packages/client/lib/commands/SMOVE.ts @@ -1,13 +1,14 @@ -// import { RedisCommandArgument, RedisCommandArguments } from '.'; +import { RedisArgument, NumberReply, Command } from '../RESP/types'; -// export const FIRST_KEY_INDEX = 1; - -// export function transformArguments( -// source: RedisCommandArgument, -// destination: RedisCommandArgument, -// member: RedisCommandArgument -// ): RedisCommandArguments { -// return ['SMOVE', source, destination, member]; -// } - -// export { transformBooleanReply as transformReply } from './generic-transformers'; +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments( + source: RedisArgument, + destination: RedisArgument, + member: RedisArgument + ) { + return ['SMOVE', source, destination, member]; + }, + transformReply: undefined as unknown as () => NumberReply +} as const satisfies Command; diff --git a/packages/client/lib/commands/index.ts b/packages/client/lib/commands/index.ts index e3985f82f8..143d9ce3ab 100644 --- a/packages/client/lib/commands/index.ts +++ b/packages/client/lib/commands/index.ts @@ -139,6 +139,7 @@ import SINTERSTORE from './SINTERSTORE'; import SISMEMBER from './SISMEMBER'; import SMEMBERS from './SMEMBERS'; import SMISMEMBER from './SMISMEMBER'; +import SMOVE from './SMOVE'; import SORT_RO from './SORT_RO'; import SORT_STORE from './SORT_STORE'; import SORT from './SORT'; @@ -479,6 +480,8 @@ export default { sMembers: SMEMBERS, SMISMEMBER, smIsMember: SMISMEMBER, + SMOVE, + sMove: SMOVE, SORT_RO, sortRo: SORT_RO, SORT_STORE, diff --git a/todo.md b/todo.md index c969748d18..3d7d0b3674 100644 --- a/todo.md +++ b/todo.md @@ -11,7 +11,6 @@ # waiting List categoreis -- List - Set - Bitmap From 92b38a1f37162cf0ea152472c55322ea4da9280f Mon Sep 17 00:00:00 2001 From: dovi Date: Wed, 3 May 2023 18:26:56 -0400 Subject: [PATCH 3/7] fix SSCAN --- packages/client/lib/commands/SSCAN.spec.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/client/lib/commands/SSCAN.spec.ts b/packages/client/lib/commands/SSCAN.spec.ts index 4cfb59445d..3fe9edec8c 100644 --- a/packages/client/lib/commands/SSCAN.spec.ts +++ b/packages/client/lib/commands/SSCAN.spec.ts @@ -40,7 +40,7 @@ describe('SSCAN', () => { }); }); - testUtils.testWithClient('client.sScan', async client => { + testUtils.testAll('sScan', async client => { assert.deepEqual( await client.sScan('key', 0), { @@ -48,5 +48,8 @@ describe('SSCAN', () => { members: [] } ); - }, GLOBAL.SERVERS.OPEN); + }, { + client: GLOBAL.SERVERS.OPEN, + cluster: GLOBAL.CLUSTERS.OPEN + }); }); From 627c9122efc839ec0632fb8a6cd0e9f5c0c7b3ba Mon Sep 17 00:00:00 2001 From: dovi Date: Wed, 3 May 2023 18:40:36 -0400 Subject: [PATCH 4/7] fix SUNION --- packages/client/lib/commands/SUNION.spec.ts | 53 +++++++++++---------- packages/client/lib/commands/SUNION.ts | 23 ++++----- packages/client/lib/commands/index.ts | 3 ++ 3 files changed, 41 insertions(+), 38 deletions(-) diff --git a/packages/client/lib/commands/SUNION.spec.ts b/packages/client/lib/commands/SUNION.spec.ts index b0ddf782f9..d91baa9c66 100644 --- a/packages/client/lib/commands/SUNION.spec.ts +++ b/packages/client/lib/commands/SUNION.spec.ts @@ -1,28 +1,31 @@ -// import { strict as assert } from 'assert'; -// import testUtils, { GLOBAL } from '../test-utils'; -// import { transformArguments } from './SUNION'; +import { strict as assert } from 'assert'; +import testUtils, { GLOBAL } from '../test-utils'; +import SUNION from './SUNION'; -// describe('SUNION', () => { -// describe('transformArguments', () => { -// it('string', () => { -// assert.deepEqual( -// transformArguments('key'), -// ['SUNION', 'key'] -// ); -// }); +describe('SUNION', () => { + describe('transformArguments', () => { + it('string', () => { + assert.deepEqual( + SUNION.transformArguments('key'), + ['SUNION', 'key'] + ); + }); -// it('array', () => { -// assert.deepEqual( -// transformArguments(['1', '2']), -// ['SUNION', '1', '2'] -// ); -// }); -// }); + it('array', () => { + assert.deepEqual( + SUNION.transformArguments(['1', '2']), + ['SUNION', '1', '2'] + ); + }); + }); -// testUtils.testWithClient('client.sUnion', async client => { -// assert.deepEqual( -// await client.sUnion('key'), -// [] -// ); -// }, GLOBAL.SERVERS.OPEN); -// }); + testUtils.testAll('sUnion', async client => { + assert.deepEqual( + await client.sUnion('key'), + [] + ); + }, { + client: GLOBAL.SERVERS.OPEN, + cluster: GLOBAL.CLUSTERS.OPEN + }); +}); diff --git a/packages/client/lib/commands/SUNION.ts b/packages/client/lib/commands/SUNION.ts index f9e7172acb..42042217e2 100644 --- a/packages/client/lib/commands/SUNION.ts +++ b/packages/client/lib/commands/SUNION.ts @@ -1,14 +1,11 @@ -// import { RedisCommandArgument, RedisCommandArguments } from '.'; -// import { pushVariadicArguments } from './generic-transformers'; +import { ArrayReply, BlobStringReply, Command } from '../RESP/types'; +import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers'; -// export const FIRST_KEY_INDEX = 1; - -// export const IS_READ_ONLY = true; - -// export function transformArguments( -// keys: RedisCommandArgument | Array -// ): RedisCommandArguments { -// return pushVariadicArguments(['SUNION'], keys); -// } - -// export declare function transformReply(): Array; +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: true, + transformArguments(keys: RedisVariadicArgument) { + return pushVariadicArguments(['SUNION'], keys); + }, + transformReply: undefined as unknown as () => ArrayReply +} as const satisfies Command; diff --git a/packages/client/lib/commands/index.ts b/packages/client/lib/commands/index.ts index 143d9ce3ab..3629b0357d 100644 --- a/packages/client/lib/commands/index.ts +++ b/packages/client/lib/commands/index.ts @@ -151,6 +151,7 @@ import SRANDMEMBER from './SRANDMEMBER'; import SREM from './SREM'; import SSCAN from './SSCAN'; import STRLEN from './STRLEN'; +import SUNION from './SUNION'; import TOUCH from './TOUCH'; import TTL from './TTL'; import TYPE from './TYPE'; @@ -504,6 +505,8 @@ export default { sScan: SSCAN, STRLEN, strLen: STRLEN, + SUNION, + sUnion: SUNION, TOUCH, touch: TOUCH, TTL, From 4de409e0ad75cc7e0645aabb11d2d26aafafa4dc Mon Sep 17 00:00:00 2001 From: dovi Date: Wed, 3 May 2023 18:51:12 -0400 Subject: [PATCH 5/7] fix SUNIONSTORE --- .../client/lib/commands/SUNIONSTORE.spec.ts | 53 ++++++++++--------- packages/client/lib/commands/SUNIONSTORE.ts | 25 ++++----- packages/client/lib/commands/index.ts | 3 ++ 3 files changed, 44 insertions(+), 37 deletions(-) diff --git a/packages/client/lib/commands/SUNIONSTORE.spec.ts b/packages/client/lib/commands/SUNIONSTORE.spec.ts index 4cf50132aa..e9d288c029 100644 --- a/packages/client/lib/commands/SUNIONSTORE.spec.ts +++ b/packages/client/lib/commands/SUNIONSTORE.spec.ts @@ -1,28 +1,31 @@ -// import { strict as assert } from 'assert'; -// import testUtils, { GLOBAL } from '../test-utils'; -// import { transformArguments } from './SUNIONSTORE'; +import { strict as assert } from 'assert'; +import testUtils, { GLOBAL } from '../test-utils'; +import SUNIONSTORE from './SUNIONSTORE'; -// describe('SUNIONSTORE', () => { -// describe('transformArguments', () => { -// it('string', () => { -// assert.deepEqual( -// transformArguments('destination', 'key'), -// ['SUNIONSTORE', 'destination', 'key'] -// ); -// }); +describe('SUNIONSTORE', () => { + describe('transformArguments', () => { + it('string', () => { + assert.deepEqual( + SUNIONSTORE.transformArguments('destination', 'key'), + ['SUNIONSTORE', 'destination', 'key'] + ); + }); -// it('array', () => { -// assert.deepEqual( -// transformArguments('destination', ['1', '2']), -// ['SUNIONSTORE', 'destination', '1', '2'] -// ); -// }); -// }); + it('array', () => { + assert.deepEqual( + SUNIONSTORE.transformArguments('destination', ['1', '2']), + ['SUNIONSTORE', 'destination', '1', '2'] + ); + }); + }); -// testUtils.testWithClient('client.sUnionStore', async client => { -// assert.equal( -// await client.sUnionStore('destination', 'key'), -// 0 -// ); -// }, GLOBAL.SERVERS.OPEN); -// }); + testUtils.testAll('sUnionStore', async client => { + assert.equal( + await client.sUnionStore('{tag}destination', '{tag}key'), + 0 + ); + }, { + client: GLOBAL.SERVERS.OPEN, + cluster: GLOBAL.CLUSTERS.OPEN + }); +}); diff --git a/packages/client/lib/commands/SUNIONSTORE.ts b/packages/client/lib/commands/SUNIONSTORE.ts index 1d5ee097ca..9adaa9288f 100644 --- a/packages/client/lib/commands/SUNIONSTORE.ts +++ b/packages/client/lib/commands/SUNIONSTORE.ts @@ -1,13 +1,14 @@ -// import { RedisCommandArgument, RedisCommandArguments } from '.'; -// import { pushVariadicArguments } from './generic-transformers'; +import { RedisArgument, NumberReply, Command } from '../RESP/types'; +import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers'; -// export const FIRST_KEY_INDEX = 1; - -// export function transformArguments( -// destination: RedisCommandArgument, -// keys: RedisCommandArgument | Array -// ): RedisCommandArguments { -// return pushVariadicArguments(['SUNIONSTORE', destination], keys); -// } - -// export declare function transformReply(): number; +export default { + FIRST_KEY_INDEX: 1, + IS_READ_ONLY: false, + transformArguments( + destination: RedisArgument, + keys: RedisVariadicArgument + ) { + return pushVariadicArguments(['SUNIONSTORE', destination], keys); + }, + transformReply: undefined as unknown as () => NumberReply +} as const satisfies Command; diff --git a/packages/client/lib/commands/index.ts b/packages/client/lib/commands/index.ts index 3629b0357d..81dc8bd13d 100644 --- a/packages/client/lib/commands/index.ts +++ b/packages/client/lib/commands/index.ts @@ -152,6 +152,7 @@ import SREM from './SREM'; import SSCAN from './SSCAN'; import STRLEN from './STRLEN'; import SUNION from './SUNION'; +import SUNIONSTORE from './SUNIONSTORE'; import TOUCH from './TOUCH'; import TTL from './TTL'; import TYPE from './TYPE'; @@ -507,6 +508,8 @@ export default { strLen: STRLEN, SUNION, sUnion: SUNION, + SUNIONSTORE, + sUnionStore: SUNIONSTORE, TOUCH, touch: TOUCH, TTL, From f6be2c77d8669ab3d94096a298853e0e7ec83eba Mon Sep 17 00:00:00 2001 From: dovi Date: Wed, 3 May 2023 18:59:43 -0400 Subject: [PATCH 6/7] fix BITCOUNT spec --- packages/client/lib/commands/BITCOUNT.spec.ts | 75 ++++++++++--------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/packages/client/lib/commands/BITCOUNT.spec.ts b/packages/client/lib/commands/BITCOUNT.spec.ts index 76e7b03f7c..6744a6014f 100644 --- a/packages/client/lib/commands/BITCOUNT.spec.ts +++ b/packages/client/lib/commands/BITCOUNT.spec.ts @@ -1,44 +1,47 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; -import { transformArguments } from './BITCOUNT'; +import BITCOUNT from './BITCOUNT'; describe('BITCOUNT', () => { - describe('transformArguments', () => { - it('simple', () => { - assert.deepEqual( - transformArguments('key'), - ['BITCOUNT', 'key'] - ); - }); - - describe('with range', () => { - it('simple', () => { - assert.deepEqual( - transformArguments('key', { - start: 0, - end: 1 - }), - ['BITCOUNT', 'key', '0', '1'] - ); - }); - - it('with mode', () => { - assert.deepEqual( - transformArguments('key', { - start: 0, - end: 1, - mode: 'BIT' - }), - ['BITCOUNT', 'key', '0', '1', 'BIT'] - ); - }); - }); + describe('transformArguments', () => { + it('simple', () => { + assert.deepEqual( + BITCOUNT.transformArguments('key'), + ['BITCOUNT', 'key'] + ); }); - testUtils.testWithClient('client.bitCount', async client => { - assert.equal( - await client.bitCount('key'), - 0 + describe('with range', () => { + it('simple', () => { + assert.deepEqual( + BITCOUNT.transformArguments('key', { + start: 0, + end: 1 + }), + ['BITCOUNT', 'key', '0', '1'] ); - }, GLOBAL.SERVERS.OPEN); + }); + + it('with mode', () => { + assert.deepEqual( + BITCOUNT.transformArguments('key', { + start: 0, + end: 1, + mode: 'BIT' + }), + ['BITCOUNT', 'key', '0', '1', 'BIT'] + ); + }); + }); + }); + + testUtils.testAll('bitCount', async client => { + assert.equal( + await client.bitCount('key'), + 0 + ); + }, { + client: GLOBAL.SERVERS.OPEN, + cluster: GLOBAL.CLUSTERS.OPEN + }); }); From d5ef57893cd0a98031293af554a383a4e996b6d3 Mon Sep 17 00:00:00 2001 From: dovi Date: Wed, 3 May 2023 19:03:43 -0400 Subject: [PATCH 7/7] fix BITPOS spec --- packages/client/lib/commands/BITPOS.spec.ts | 80 ++++++++++----------- 1 file changed, 38 insertions(+), 42 deletions(-) diff --git a/packages/client/lib/commands/BITPOS.spec.ts b/packages/client/lib/commands/BITPOS.spec.ts index 2a0758fe5d..8891f43a15 100644 --- a/packages/client/lib/commands/BITPOS.spec.ts +++ b/packages/client/lib/commands/BITPOS.spec.ts @@ -1,49 +1,45 @@ import { strict as assert } from 'assert'; import testUtils, { GLOBAL } from '../test-utils'; -import { transformArguments } from './BITPOS'; +import BITPOS from './BITPOS'; -describe('BITPOS', () => { - describe('transformArguments', () => { - it('simple', () => { - assert.deepEqual( - transformArguments('key', 1), - ['BITPOS', 'key', '1'] - ); - }); - - it('with start', () => { - assert.deepEqual( - transformArguments('key', 1, 1), - ['BITPOS', 'key', '1', '1'] - ); - }); - - it('with start and end', () => { - assert.deepEqual( - transformArguments('key', 1, 1, -1), - ['BITPOS', 'key', '1', '1', '-1'] - ); - }); - - it('with start, end and mode', () => { - assert.deepEqual( - transformArguments('key', 1, 1, -1, 'BIT'), - ['BITPOS', 'key', '1', '1', '-1', 'BIT'] - ); - }); +describe.only('BITPOS', () => { + describe('transformArguments', () => { + it('simple', () => { + assert.deepEqual( + BITPOS.transformArguments('key', 1), + ['BITPOS', 'key', '1'] + ); }); - testUtils.testWithClient('client.bitPos', async client => { - assert.equal( - await client.bitPos('key', 1, 1), - -1 - ); - }, GLOBAL.SERVERS.OPEN); + it('with start', () => { + assert.deepEqual( + BITPOS.transformArguments('key', 1, 1), + ['BITPOS', 'key', '1', '1'] + ); + }); - testUtils.testWithCluster('cluster.bitPos', async cluster => { - assert.equal( - await cluster.bitPos('key', 1, 1), - -1 - ); - }, GLOBAL.CLUSTERS.OPEN); + it('with start and end', () => { + assert.deepEqual( + BITPOS.transformArguments('key', 1, 1, -1), + ['BITPOS', 'key', '1', '1', '-1'] + ); + }); + + it('with start, end and mode', () => { + assert.deepEqual( + BITPOS.transformArguments('key', 1, 1, -1, 'BIT'), + ['BITPOS', 'key', '1', '1', '-1', 'BIT'] + ); + }); + }); + + testUtils.testAll('bitPos', async client => { + assert.equal( + await client.bitPos('key', 1, 1), + -1 + ); + }, { + client: GLOBAL.SERVERS.OPEN, + cluster: GLOBAL.CLUSTERS.OPEN + }); });