1
1
import { strict as assert } from 'assert' ;
2
2
import { TestRedisServers , itWithClient , itWithCluster , TestRedisClusters } from '../test-utils' ;
3
- import { transformArguments } from './XREADGROUP' ;
3
+ import { FIRST_KEY_INDEX , transformArguments } from './XREADGROUP' ;
4
4
5
5
describe ( 'XREADGROUP' , ( ) => {
6
+ describe ( 'FIRST_KEY_INDEX' , ( ) => {
7
+ it ( 'single stream' , ( ) => {
8
+ assert . equal (
9
+ FIRST_KEY_INDEX ( '' , '' , { key : 'key' , id : '' } ) ,
10
+ 'key'
11
+ ) ;
12
+ } ) ;
13
+
14
+ it ( 'multiple streams' , ( ) => {
15
+ assert . equal (
16
+ FIRST_KEY_INDEX ( '' , '' , [ { key : '1' , id : '' } , { key : '2' , id : '' } ] ) ,
17
+ '1'
18
+ ) ;
19
+ } ) ;
20
+ } ) ;
21
+
6
22
describe ( 'transformArguments' , ( ) => {
7
23
it ( 'single stream' , ( ) => {
8
24
assert . deepEqual (
@@ -78,13 +94,27 @@ describe('XREADGROUP', () => {
78
94
} ) ;
79
95
} ) ;
80
96
81
- describe ( 'client.xReadGroup' , ( ) => {
82
- itWithClient ( TestRedisServers . OPEN , 'null' , async client => {
97
+ itWithClient ( TestRedisServers . OPEN , 'null' , async client => {
98
+ const [ , readGroupReply ] = await Promise . all ( [
99
+ client . xGroupCreate ( 'key' , 'group' , '$' , {
100
+ MKSTREAM : true
101
+ } ) ,
102
+ client . xReadGroup ( 'group' , 'consumer' , {
103
+ key : 'key' ,
104
+ id : '>'
105
+ } )
106
+ ] ) ;
107
+
108
+ assert . equal ( readGroupReply , null ) ;
109
+ } ) ;
110
+
111
+ describe ( 'cluster.xReadGroup' , ( ) => {
112
+ itWithCluster ( TestRedisClusters . OPEN , 'null' , async cluster => {
83
113
const [ , readGroupReply ] = await Promise . all ( [
84
- client . xGroupCreate ( 'key' , 'group' , '$' , {
114
+ cluster . xGroupCreate ( 'key' , 'group' , '$' , {
85
115
MKSTREAM : true
86
116
} ) ,
87
- client . xReadGroup ( 'group' , 'consumer' , {
117
+ cluster . xReadGroup ( 'group' , 'consumer' , {
88
118
key : 'key' ,
89
119
id : '>'
90
120
} )
@@ -93,7 +123,7 @@ describe('XREADGROUP', () => {
93
123
assert . equal ( readGroupReply , null ) ;
94
124
} ) ;
95
125
96
- itWithClient ( TestRedisServers . OPEN , 'with a message' , async client => {
126
+ itWithCluster ( TestRedisClusters . OPEN , 'with a message' , async client => {
97
127
const [ , id , readGroupReply ] = await Promise . all ( [
98
128
client . xGroupCreate ( 'key' , 'group' , '$' , {
99
129
MKSTREAM : true
@@ -120,18 +150,4 @@ describe('XREADGROUP', () => {
120
150
} ] ) ;
121
151
} ) ;
122
152
} ) ;
123
-
124
- itWithCluster ( TestRedisClusters . OPEN , 'cluster.xReadGroup' , async cluster => {
125
- const [ , readGroupReply ] = await Promise . all ( [
126
- cluster . xGroupCreate ( 'key' , 'group' , '$' , {
127
- MKSTREAM : true
128
- } ) ,
129
- cluster . xReadGroup ( 'group' , 'consumer' , {
130
- key : 'key' ,
131
- id : '>'
132
- } )
133
- ] ) ;
134
-
135
- assert . equal ( readGroupReply , null ) ;
136
- } ) ;
137
153
} ) ;
0 commit comments