You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-09-11 18:50:46 +03:00
* update workflows & README
* add .deepsource.toml
* fix client.quit, add error events on cluster, fix some "deepsource.io" warnings
* Release 4.0.0-rc.1
* add cluster.duplicate, add some tests
* fix #1650 - add support for Buffer in some commands, add GET_BUFFER command
* fix GET and GET_BUFFER return type
* update FAQ
* Update invalid code example in README.md (#1654)
* Update invalid code example in README.md
* Update README.md
Co-authored-by: Leibale Eidelman <leibale1998@gmail.com>
* fix #1652
* ref #1653 - better types
* better types
* fix 54124793ad
* Update GEOSEARCHSTORE.spec.ts
* fix #1660 - add support for client.HSET('key', 'field', 'value')
* upgrade dependencies, update README
* fix #1659 - add support for db-number in client options url
* fix README, remove unused import, downgrade typedoc & typedoc-plugin-markdown
* update client-configurations.md
* fix README
* add CLUSTER_SLOTS, add some tests
* fix "createClient with url" test with redis 5
* remove unused imports
* Release 4.0.0-rc.2
* add missing semicolon
* replace empty "transformReply" functions with typescript "declare"
* fix EVAL & EVALSHA, add some tests, npm update
* fix #1665 - add ZRANGEBYLEX, ZRANGEBYSCORE, ZRANGEBYSCORE_WITHSCORES
* new issue templates
* add all COMMAND commands
* run COMMAND & COMMAND INFO tests only on redis >6
* Create SECURITY.md
* fix #1671 - add support for all client configurations in cluster
* ref #1671 - add support for defaults
* remove some commands from cluster, npm update, clean code,
* lock benny version
* fix #1674 - remove `isolationPoolOptions` when creating isolated connection
* increase test coverage
* update .npmignore
* Release 4.0.0-rc.3
Co-authored-by: Richard Samuelsson <noobtoothfairy@gmail.com>
104 lines
2.7 KiB
TypeScript
104 lines
2.7 KiB
TypeScript
import { strict as assert } from 'assert';
|
|
import { TestRedisServers, itWithClient, itWithCluster, TestRedisClusters } from '../test-utils';
|
|
import { FIRST_KEY_INDEX, transformArguments } from './XREAD';
|
|
|
|
describe('XREAD', () => {
|
|
describe('FIRST_KEY_INDEX', () => {
|
|
it('single stream', () => {
|
|
assert.equal(
|
|
FIRST_KEY_INDEX({ key: 'key', id: '' }),
|
|
'key'
|
|
);
|
|
});
|
|
|
|
it('multiple streams', () => {
|
|
assert.equal(
|
|
FIRST_KEY_INDEX([{ key: '1', id: '' }, { key: '2', id: '' }]),
|
|
'1'
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('transformArguments', () => {
|
|
it('single stream', () => {
|
|
assert.deepEqual(
|
|
transformArguments({
|
|
key: 'key',
|
|
id: '0'
|
|
}),
|
|
['XREAD', 'STREAMS', 'key', '0']
|
|
);
|
|
});
|
|
|
|
it('multiple streams', () => {
|
|
assert.deepEqual(
|
|
transformArguments([{
|
|
key: '1',
|
|
id: '0'
|
|
}, {
|
|
key: '2',
|
|
id: '0'
|
|
}]),
|
|
['XREAD', 'STREAMS', '1', '2', '0', '0']
|
|
);
|
|
});
|
|
|
|
it('with COUNT', () => {
|
|
assert.deepEqual(
|
|
transformArguments({
|
|
key: 'key',
|
|
id: '0'
|
|
}, {
|
|
COUNT: 1
|
|
}),
|
|
['XREAD', 'COUNT', '1', 'STREAMS', 'key', '0']
|
|
);
|
|
});
|
|
|
|
it('with BLOCK', () => {
|
|
assert.deepEqual(
|
|
transformArguments({
|
|
key: 'key',
|
|
id: '0'
|
|
}, {
|
|
BLOCK: 0
|
|
}),
|
|
['XREAD', 'BLOCK', '0', 'STREAMS', 'key', '0']
|
|
);
|
|
});
|
|
|
|
it('with COUNT, BLOCK', () => {
|
|
assert.deepEqual(
|
|
transformArguments({
|
|
key: 'key',
|
|
id: '0'
|
|
}, {
|
|
COUNT: 1,
|
|
BLOCK: 0
|
|
}),
|
|
['XREAD', 'COUNT', '1', 'BLOCK', '0', 'STREAMS', 'key', '0']
|
|
);
|
|
});
|
|
});
|
|
|
|
itWithClient(TestRedisServers.OPEN, 'client.xRead', async client => {
|
|
assert.equal(
|
|
await client.xRead({
|
|
key: 'key',
|
|
id: '0'
|
|
}),
|
|
null
|
|
);
|
|
});
|
|
|
|
itWithCluster(TestRedisClusters.OPEN, 'cluster.xRead', async cluster => {
|
|
assert.equal(
|
|
await cluster.xRead({
|
|
key: 'key',
|
|
id: '0'
|
|
}),
|
|
null
|
|
);
|
|
});
|
|
});
|