Skip to content

Commit c6f9f6e

Browse files
committed
Merge branch 'v5' of github.com:leibale/node-redis into v5
2 parents 01e6821 + d5ef578 commit c6f9f6e

File tree

14 files changed

+202
-186
lines changed

14 files changed

+202
-186
lines changed

docs/v4-to-v5.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ Some command arguments/replies have changed to align more closely to data types
9999
- `SCRIPT EXISTS`: `Array<boolean>` -> `Array<number>` [^boolean-to-number]
100100
- `SISMEMBER`: `boolean` -> `number` [^boolean-to-number]
101101
- `SMISMEMBER`: `Array<boolean>` -> `Array<number>` [^boolean-to-number]
102+
- `SMOVE`: `boolean` -> `number` [^boolean-to-number]
102103
- `TS.ADD`: `boolean` -> `number` [^boolean-to-number]
103104
- `GEOSEARCH_WITH`/`GEORADIUS_WITH`: `GeoReplyWith` -> `GEO_REPLY_WITH` [^enum-to-constants]
104105
- `GEORADIUSSTORE` -> `GEORADIUS_STORE`
Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,47 @@
11
import { strict as assert } from 'assert';
22
import testUtils, { GLOBAL } from '../test-utils';
3-
import { transformArguments } from './BITCOUNT';
3+
import BITCOUNT from './BITCOUNT';
44

55
describe('BITCOUNT', () => {
6-
describe('transformArguments', () => {
7-
it('simple', () => {
8-
assert.deepEqual(
9-
transformArguments('key'),
10-
['BITCOUNT', 'key']
11-
);
12-
});
6+
describe('transformArguments', () => {
7+
it('simple', () => {
8+
assert.deepEqual(
9+
BITCOUNT.transformArguments('key'),
10+
['BITCOUNT', 'key']
11+
);
12+
});
1313

14-
describe('with range', () => {
15-
it('simple', () => {
16-
assert.deepEqual(
17-
transformArguments('key', {
18-
start: 0,
19-
end: 1
20-
}),
21-
['BITCOUNT', 'key', '0', '1']
22-
);
23-
});
14+
describe('with range', () => {
15+
it('simple', () => {
16+
assert.deepEqual(
17+
BITCOUNT.transformArguments('key', {
18+
start: 0,
19+
end: 1
20+
}),
21+
['BITCOUNT', 'key', '0', '1']
22+
);
23+
});
2424

25-
it('with mode', () => {
26-
assert.deepEqual(
27-
transformArguments('key', {
28-
start: 0,
29-
end: 1,
30-
mode: 'BIT'
31-
}),
32-
['BITCOUNT', 'key', '0', '1', 'BIT']
33-
);
34-
});
35-
});
25+
it('with mode', () => {
26+
assert.deepEqual(
27+
BITCOUNT.transformArguments('key', {
28+
start: 0,
29+
end: 1,
30+
mode: 'BIT'
31+
}),
32+
['BITCOUNT', 'key', '0', '1', 'BIT']
33+
);
34+
});
3635
});
36+
});
3737

38-
testUtils.testWithClient('client.bitCount', async client => {
39-
assert.equal(
40-
await client.bitCount('key'),
41-
0
42-
);
43-
}, GLOBAL.SERVERS.OPEN);
38+
testUtils.testAll('bitCount', async client => {
39+
assert.equal(
40+
await client.bitCount('key'),
41+
0
42+
);
43+
}, {
44+
client: GLOBAL.SERVERS.OPEN,
45+
cluster: GLOBAL.CLUSTERS.OPEN
46+
});
4447
});
Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,45 @@
11
import { strict as assert } from 'assert';
22
import testUtils, { GLOBAL } from '../test-utils';
3-
import { transformArguments } from './BITPOS';
3+
import BITPOS from './BITPOS';
44

5-
describe('BITPOS', () => {
6-
describe('transformArguments', () => {
7-
it('simple', () => {
8-
assert.deepEqual(
9-
transformArguments('key', 1),
10-
['BITPOS', 'key', '1']
11-
);
12-
});
13-
14-
it('with start', () => {
15-
assert.deepEqual(
16-
transformArguments('key', 1, 1),
17-
['BITPOS', 'key', '1', '1']
18-
);
19-
});
5+
describe.only('BITPOS', () => {
6+
describe('transformArguments', () => {
7+
it('simple', () => {
8+
assert.deepEqual(
9+
BITPOS.transformArguments('key', 1),
10+
['BITPOS', 'key', '1']
11+
);
12+
});
2013

21-
it('with start and end', () => {
22-
assert.deepEqual(
23-
transformArguments('key', 1, 1, -1),
24-
['BITPOS', 'key', '1', '1', '-1']
25-
);
26-
});
14+
it('with start', () => {
15+
assert.deepEqual(
16+
BITPOS.transformArguments('key', 1, 1),
17+
['BITPOS', 'key', '1', '1']
18+
);
19+
});
2720

28-
it('with start, end and mode', () => {
29-
assert.deepEqual(
30-
transformArguments('key', 1, 1, -1, 'BIT'),
31-
['BITPOS', 'key', '1', '1', '-1', 'BIT']
32-
);
33-
});
21+
it('with start and end', () => {
22+
assert.deepEqual(
23+
BITPOS.transformArguments('key', 1, 1, -1),
24+
['BITPOS', 'key', '1', '1', '-1']
25+
);
3426
});
3527

36-
testUtils.testWithClient('client.bitPos', async client => {
37-
assert.equal(
38-
await client.bitPos('key', 1, 1),
39-
-1
40-
);
41-
}, GLOBAL.SERVERS.OPEN);
28+
it('with start, end and mode', () => {
29+
assert.deepEqual(
30+
BITPOS.transformArguments('key', 1, 1, -1, 'BIT'),
31+
['BITPOS', 'key', '1', '1', '-1', 'BIT']
32+
);
33+
});
34+
});
4235

43-
testUtils.testWithCluster('cluster.bitPos', async cluster => {
44-
assert.equal(
45-
await cluster.bitPos('key', 1, 1),
46-
-1
47-
);
48-
}, GLOBAL.CLUSTERS.OPEN);
36+
testUtils.testAll('bitPos', async client => {
37+
assert.equal(
38+
await client.bitPos('key', 1, 1),
39+
-1
40+
);
41+
}, {
42+
client: GLOBAL.SERVERS.OPEN,
43+
cluster: GLOBAL.CLUSTERS.OPEN
44+
});
4945
});

packages/client/lib/commands/LRANGE.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import { strict as assert } from 'assert';
32
import testUtils, { GLOBAL } from '../test-utils';
43
import LRANGE from './LRANGE';

packages/client/lib/commands/LREM.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import { strict as assert } from 'assert';
32
import testUtils, { GLOBAL } from '../test-utils';
43
import LREM from './LREM';
Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
// import { strict as assert } from 'assert';
2-
// import testUtils, { GLOBAL } from '../test-utils';
3-
// import { transformArguments } from './SMOVE';
1+
import { strict as assert } from 'assert';
2+
import testUtils, { GLOBAL } from '../test-utils';
3+
import SMOVE from './SMOVE';
44

5-
// describe('SMOVE', () => {
6-
// it('transformArguments', () => {
7-
// assert.deepEqual(
8-
// transformArguments('source', 'destination', 'member'),
9-
// ['SMOVE', 'source', 'destination', 'member']
10-
// );
11-
// });
5+
describe('SMOVE', () => {
6+
it('transformArguments', () => {
7+
assert.deepEqual(
8+
SMOVE.transformArguments('source', 'destination', 'member'),
9+
['SMOVE', 'source', 'destination', 'member']
10+
);
11+
});
1212

13-
// testUtils.testWithClient('client.sMove', async client => {
14-
// assert.equal(
15-
// await client.sMove('source', 'destination', 'member'),
16-
// false
17-
// );
18-
// }, GLOBAL.SERVERS.OPEN);
19-
// });
13+
testUtils.testAll('sMove', async client => {
14+
assert.equal(
15+
await client.sMove('{tag}source', '{tag}destination', 'member'),
16+
0
17+
);
18+
}, {
19+
client: GLOBAL.SERVERS.OPEN,
20+
cluster: GLOBAL.CLUSTERS.OPEN
21+
});
22+
});

packages/client/lib/commands/SMOVE.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
// import { RedisCommandArgument, RedisCommandArguments } from '.';
1+
import { RedisArgument, NumberReply, Command } from '../RESP/types';
22

3-
// export const FIRST_KEY_INDEX = 1;
4-
5-
// export function transformArguments(
6-
// source: RedisCommandArgument,
7-
// destination: RedisCommandArgument,
8-
// member: RedisCommandArgument
9-
// ): RedisCommandArguments {
10-
// return ['SMOVE', source, destination, member];
11-
// }
12-
13-
// export { transformBooleanReply as transformReply } from './generic-transformers';
3+
export default {
4+
FIRST_KEY_INDEX: 1,
5+
IS_READ_ONLY: false,
6+
transformArguments(
7+
source: RedisArgument,
8+
destination: RedisArgument,
9+
member: RedisArgument
10+
) {
11+
return ['SMOVE', source, destination, member];
12+
},
13+
transformReply: undefined as unknown as () => NumberReply
14+
} as const satisfies Command;

packages/client/lib/commands/SSCAN.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,16 @@ describe('SSCAN', () => {
4040
});
4141
});
4242

43-
testUtils.testWithClient('client.sScan', async client => {
43+
testUtils.testAll('sScan', async client => {
4444
assert.deepEqual(
4545
await client.sScan('key', 0),
4646
{
4747
cursor: 0,
4848
members: []
4949
}
5050
);
51-
}, GLOBAL.SERVERS.OPEN);
51+
}, {
52+
client: GLOBAL.SERVERS.OPEN,
53+
cluster: GLOBAL.CLUSTERS.OPEN
54+
});
5255
});
Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
1-
// import { strict as assert } from 'assert';
2-
// import testUtils, { GLOBAL } from '../test-utils';
3-
// import { transformArguments } from './SUNION';
1+
import { strict as assert } from 'assert';
2+
import testUtils, { GLOBAL } from '../test-utils';
3+
import SUNION from './SUNION';
44

5-
// describe('SUNION', () => {
6-
// describe('transformArguments', () => {
7-
// it('string', () => {
8-
// assert.deepEqual(
9-
// transformArguments('key'),
10-
// ['SUNION', 'key']
11-
// );
12-
// });
5+
describe('SUNION', () => {
6+
describe('transformArguments', () => {
7+
it('string', () => {
8+
assert.deepEqual(
9+
SUNION.transformArguments('key'),
10+
['SUNION', 'key']
11+
);
12+
});
1313

14-
// it('array', () => {
15-
// assert.deepEqual(
16-
// transformArguments(['1', '2']),
17-
// ['SUNION', '1', '2']
18-
// );
19-
// });
20-
// });
14+
it('array', () => {
15+
assert.deepEqual(
16+
SUNION.transformArguments(['1', '2']),
17+
['SUNION', '1', '2']
18+
);
19+
});
20+
});
2121

22-
// testUtils.testWithClient('client.sUnion', async client => {
23-
// assert.deepEqual(
24-
// await client.sUnion('key'),
25-
// []
26-
// );
27-
// }, GLOBAL.SERVERS.OPEN);
28-
// });
22+
testUtils.testAll('sUnion', async client => {
23+
assert.deepEqual(
24+
await client.sUnion('key'),
25+
[]
26+
);
27+
}, {
28+
client: GLOBAL.SERVERS.OPEN,
29+
cluster: GLOBAL.CLUSTERS.OPEN
30+
});
31+
});
Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
// import { RedisCommandArgument, RedisCommandArguments } from '.';
2-
// import { pushVariadicArguments } from './generic-transformers';
3-
4-
// export const FIRST_KEY_INDEX = 1;
5-
6-
// export const IS_READ_ONLY = true;
7-
8-
// export function transformArguments(
9-
// keys: RedisCommandArgument | Array<RedisCommandArgument>
10-
// ): RedisCommandArguments {
11-
// return pushVariadicArguments(['SUNION'], keys);
12-
// }
13-
14-
// export declare function transformReply(): Array<RedisCommandArgument>;
1+
import { ArrayReply, BlobStringReply, Command } from '../RESP/types';
2+
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers';
3+
4+
export default {
5+
FIRST_KEY_INDEX: 1,
6+
IS_READ_ONLY: true,
7+
transformArguments(keys: RedisVariadicArgument) {
8+
return pushVariadicArguments(['SUNION'], keys);
9+
},
10+
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply>
11+
} as const satisfies Command;

0 commit comments

Comments
 (0)