-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v5' of github.com:leibale/node-redis into v5
- Loading branch information
Showing
14 changed files
with
202 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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('transformArguments', () => { | ||
it('simple', () => { | ||
assert.deepEqual( | ||
BITCOUNT.transformArguments('key'), | ||
['BITCOUNT', 'key'] | ||
); | ||
}); | ||
|
||
describe('with range', () => { | ||
it('simple', () => { | ||
assert.deepEqual( | ||
transformArguments('key', { | ||
start: 0, | ||
end: 1 | ||
}), | ||
['BITCOUNT', 'key', '0', '1'] | ||
); | ||
}); | ||
describe('with range', () => { | ||
it('simple', () => { | ||
assert.deepEqual( | ||
BITCOUNT.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'] | ||
); | ||
}); | ||
}); | ||
it('with mode', () => { | ||
assert.deepEqual( | ||
BITCOUNT.transformArguments('key', { | ||
start: 0, | ||
end: 1, | ||
mode: 'BIT' | ||
}), | ||
['BITCOUNT', 'key', '0', '1', 'BIT'] | ||
); | ||
}); | ||
}); | ||
}); | ||
|
||
testUtils.testWithClient('client.bitCount', async client => { | ||
assert.equal( | ||
await client.bitCount('key'), | ||
0 | ||
); | ||
}, GLOBAL.SERVERS.OPEN); | ||
testUtils.testAll('bitCount', async client => { | ||
assert.equal( | ||
await client.bitCount('key'), | ||
0 | ||
); | ||
}, { | ||
client: GLOBAL.SERVERS.OPEN, | ||
cluster: GLOBAL.CLUSTERS.OPEN | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'] | ||
); | ||
}); | ||
describe.only('BITPOS', () => { | ||
describe('transformArguments', () => { | ||
it('simple', () => { | ||
assert.deepEqual( | ||
BITPOS.transformArguments('key', 1), | ||
['BITPOS', 'key', '1'] | ||
); | ||
}); | ||
|
||
it('with start and end', () => { | ||
assert.deepEqual( | ||
transformArguments('key', 1, 1, -1), | ||
['BITPOS', 'key', '1', '1', '-1'] | ||
); | ||
}); | ||
it('with start', () => { | ||
assert.deepEqual( | ||
BITPOS.transformArguments('key', 1, 1), | ||
['BITPOS', 'key', '1', '1'] | ||
); | ||
}); | ||
|
||
it('with start, end and mode', () => { | ||
assert.deepEqual( | ||
transformArguments('key', 1, 1, -1, 'BIT'), | ||
['BITPOS', 'key', '1', '1', '-1', 'BIT'] | ||
); | ||
}); | ||
it('with start and end', () => { | ||
assert.deepEqual( | ||
BITPOS.transformArguments('key', 1, 1, -1), | ||
['BITPOS', 'key', '1', '1', '-1'] | ||
); | ||
}); | ||
|
||
testUtils.testWithClient('client.bitPos', async client => { | ||
assert.equal( | ||
await client.bitPos('key', 1, 1), | ||
-1 | ||
); | ||
}, GLOBAL.SERVERS.OPEN); | ||
it('with start, end and mode', () => { | ||
assert.deepEqual( | ||
BITPOS.transformArguments('key', 1, 1, -1, 'BIT'), | ||
['BITPOS', 'key', '1', '1', '-1', 'BIT'] | ||
); | ||
}); | ||
}); | ||
|
||
testUtils.testWithCluster('cluster.bitPos', async cluster => { | ||
assert.equal( | ||
await cluster.bitPos('key', 1, 1), | ||
-1 | ||
); | ||
}, GLOBAL.CLUSTERS.OPEN); | ||
testUtils.testAll('bitPos', async client => { | ||
assert.equal( | ||
await client.bitPos('key', 1, 1), | ||
-1 | ||
); | ||
}, { | ||
client: GLOBAL.SERVERS.OPEN, | ||
cluster: GLOBAL.CLUSTERS.OPEN | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
// import { RedisCommandArgument, RedisCommandArguments } from '.'; | ||
// import { pushVariadicArguments } from './generic-transformers'; | ||
|
||
// export const FIRST_KEY_INDEX = 1; | ||
|
||
// export const IS_READ_ONLY = true; | ||
|
||
// export function transformArguments( | ||
// keys: RedisCommandArgument | Array<RedisCommandArgument> | ||
// ): RedisCommandArguments { | ||
// return pushVariadicArguments(['SUNION'], keys); | ||
// } | ||
|
||
// export declare function transformReply(): Array<RedisCommandArgument>; | ||
import { ArrayReply, BlobStringReply, Command } from '../RESP/types'; | ||
import { RedisVariadicArgument, pushVariadicArguments } from './generic-transformers'; | ||
|
||
export default { | ||
FIRST_KEY_INDEX: 1, | ||
IS_READ_ONLY: true, | ||
transformArguments(keys: RedisVariadicArgument) { | ||
return pushVariadicArguments(['SUNION'], keys); | ||
}, | ||
transformReply: undefined as unknown as () => ArrayReply<BlobStringReply> | ||
} as const satisfies Command; |
Oops, something went wrong.