@@ -93,6 +93,33 @@ describe('XREADGROUP', () => {
9393 [ 'XREADGROUP' , 'GROUP' , 'group' , 'consumer' , 'COUNT' , '1' , 'BLOCK' , '0' , 'NOACK' , 'STREAMS' , 'key' , '0-0' ]
9494 ) ;
9595 } ) ;
96+
97+ it ( 'with CLAIM' , ( ) => {
98+ assert . deepEqual (
99+ parseArgs ( XREADGROUP , 'group' , 'consumer' , {
100+ key : 'key' ,
101+ id : '0-0'
102+ } , {
103+ CLAIM : 100
104+ } ) ,
105+ [ 'XREADGROUP' , 'GROUP' , 'group' , 'consumer' , 'CLAIM' , '100' , 'STREAMS' , 'key' , '0-0' ]
106+ ) ;
107+ } ) ;
108+
109+ it ( 'with COUNT, BLOCK, NOACK, CLAIM' , ( ) => {
110+ assert . deepEqual (
111+ parseArgs ( XREADGROUP , 'group' , 'consumer' , {
112+ key : 'key' ,
113+ id : '0-0'
114+ } , {
115+ COUNT : 1 ,
116+ BLOCK : 0 ,
117+ NOACK : true ,
118+ CLAIM : 100
119+ } ) ,
120+ [ 'XREADGROUP' , 'GROUP' , 'group' , 'consumer' , 'COUNT' , '1' , 'BLOCK' , '0' , 'NOACK' , 'CLAIM' , '100' , 'STREAMS' , 'key' , '0-0' ]
121+ ) ;
122+ } ) ;
96123 } ) ;
97124
98125 testUtils . testAll ( 'xReadGroup - null' , async client => {
@@ -156,35 +183,57 @@ describe('XREADGROUP', () => {
156183 cluster : GLOBAL . CLUSTERS . OPEN
157184 } ) ;
158185
159- testUtils . testWithClient ( 'client.xReadGroup should throw with resp3 and unstableResp3: false' , async client => {
160- assert . throws (
161- ( ) => client . xReadGroup ( 'group' , 'consumer' , {
162- key : 'key' ,
163- id : '>'
186+ testUtils . testAll ( 'xReadGroup - without CLAIM should not include delivery fields' , async client => {
187+ const [ , id ] = await Promise . all ( [
188+ client . xGroupCreate ( 'key' , 'group' , '$' , {
189+ MKSTREAM : true
164190 } ) ,
165- {
166- message : 'Some RESP3 results for Redis Query Engine responses may change. Refer to the readme for guidance'
167- }
168- ) ;
191+ client . xAdd ( 'key' , '*' , { field : 'value' } )
192+ ] ) ;
193+
194+ const readGroupReply = await client . xReadGroup ( 'group' , 'consumer' , {
195+ key : 'key' ,
196+ id : '>'
197+ } ) ;
198+
199+ assert . ok ( readGroupReply ) ;
200+ assert . equal ( readGroupReply [ 0 ] . messages [ 0 ] . millisElapsedFromDelivery , undefined ) ;
201+ assert . equal ( readGroupReply [ 0 ] . messages [ 0 ] . deliveriesCounter , undefined ) ;
169202 } , {
170- ...GLOBAL . SERVERS . OPEN ,
171- clientOptions : {
172- RESP : 3
173- }
203+ client : GLOBAL . SERVERS . OPEN ,
204+ cluster : GLOBAL . CLUSTERS . OPEN
174205 } ) ;
175206
176- testUtils . testWithClient ( 'client.xReadGroup should not throw with resp3 and unstableResp3: true' , async client => {
177- assert . doesNotThrow (
178- ( ) => client . xReadGroup ( 'group' , 'consumer' , {
179- key : 'key' ,
180- id : '>'
181- } )
182- ) ;
207+ testUtils . testAll ( 'xReadGroup - with CLAIM should include delivery fields' , async client => {
208+ const [ , id ] = await Promise . all ( [
209+ client . xGroupCreate ( 'key' , 'group' , '$' , {
210+ MKSTREAM : true
211+ } ) ,
212+ client . xAdd ( 'key' , '*' , { field : 'value' } )
213+ ] ) ;
214+
215+ // First read to add message to PEL
216+ await client . xReadGroup ( 'group' , 'consumer' , {
217+ key : 'key' ,
218+ id : '>'
219+ } ) ;
220+
221+ // Read with CLAIM to get delivery fields
222+ const readGroupReply = await client . xReadGroup ( 'group' , 'consumer2' , {
223+ key : 'key' ,
224+ id : '>'
225+ } , {
226+ CLAIM : 0
227+ } ) ;
228+
229+ assert . ok ( readGroupReply ) ;
230+ assert . equal ( readGroupReply [ 0 ] . messages [ 0 ] . id , id ) ;
231+ assert . ok ( readGroupReply [ 0 ] . messages [ 0 ] . millisElapsedFromDelivery !== undefined ) ;
232+ assert . ok ( readGroupReply [ 0 ] . messages [ 0 ] . deliveriesCounter !== undefined ) ;
233+ assert . equal ( typeof readGroupReply [ 0 ] . messages [ 0 ] . millisElapsedFromDelivery , 'number' ) ;
234+ assert . equal ( typeof readGroupReply [ 0 ] . messages [ 0 ] . deliveriesCounter , 'number' ) ;
183235 } , {
184- ...GLOBAL . SERVERS . OPEN ,
185- clientOptions : {
186- RESP : 3 ,
187- unstableResp3 : true
188- }
236+ client : GLOBAL . SERVERS . OPEN ,
237+ cluster : GLOBAL . CLUSTERS . OPEN
189238 } ) ;
190239} ) ;
0 commit comments