@@ -23,20 +23,76 @@ describe('XAUTOCLAIM', () => {
23
23
} ) ;
24
24
} ) ;
25
25
26
- testUtils . testWithClient ( 'client.xAutoClaim' , async client => {
27
- await Promise . all ( [
28
- client . xGroupCreate ( 'key' , 'group' , '$' , {
29
- MKSTREAM : true
30
- } ) ,
26
+ testUtils . testWithClient ( 'client.xAutoClaim without messages' , async client => {
27
+ const [ , , reply ] = await Promise . all ( [
28
+ client . xGroupCreate ( 'key' , 'group' , '$' , { MKSTREAM : true } ) ,
31
29
client . xGroupCreateConsumer ( 'key' , 'group' , 'consumer' ) ,
30
+ client . xAutoClaim ( 'key' , 'group' , 'consumer' , 1 , '0-0' )
32
31
] ) ;
33
32
34
- assert . deepEqual (
35
- await client . xAutoClaim ( 'key' , 'group' , 'consumer' , 1 , '0-0' ) ,
36
- {
37
- nextId : '0-0' ,
38
- messages : [ ]
39
- }
40
- ) ;
33
+ assert . deepEqual ( reply , {
34
+ nextId : '0-0' ,
35
+ messages : [ ]
36
+ } ) ;
37
+ } , GLOBAL . SERVERS . OPEN ) ;
38
+
39
+ testUtils . testWithClient ( 'client.xAutoClaim with messages' , async client => {
40
+ const [ , , id , , reply ] = await Promise . all ( [
41
+ client . xGroupCreate ( 'key' , 'group' , '$' , { MKSTREAM : true } ) ,
42
+ client . xGroupCreateConsumer ( 'key' , 'group' , 'consumer' ) ,
43
+ client . xAdd ( 'key' , '*' , { foo : 'bar' } ) ,
44
+ client . xReadGroup ( 'group' , 'consumer' , { key : 'key' , id : '>' } ) ,
45
+ client . xAutoClaim ( 'key' , 'group' , 'consumer' , 0 , '0-0' )
46
+ ] ) ;
47
+
48
+ assert . deepEqual ( reply , {
49
+ nextId : '0-0' ,
50
+ messages : [ {
51
+ id,
52
+ message : Object . create ( null , {
53
+ foo : {
54
+ value : 'bar' ,
55
+ configurable : true ,
56
+ enumerable : true
57
+ }
58
+ } )
59
+ } ]
60
+ } ) ;
61
+ } , GLOBAL . SERVERS . OPEN ) ;
62
+
63
+ testUtils . testWithClient ( 'client.xAutoClaim with trimmed messages' , async client => {
64
+ const [ , , , , , id , , reply ] = await Promise . all ( [
65
+ client . xGroupCreate ( 'key' , 'group' , '$' , { MKSTREAM : true } ) ,
66
+ client . xGroupCreateConsumer ( 'key' , 'group' , 'consumer' ) ,
67
+ client . xAdd ( 'key' , '*' , { foo : 'bar' } ) ,
68
+ client . xReadGroup ( 'group' , 'consumer' , { key : 'key' , id : '>' } ) ,
69
+ client . xTrim ( 'key' , 'MAXLEN' , 0 ) ,
70
+ client . xAdd ( 'key' , '*' , { bar : 'baz' } ) ,
71
+ client . xReadGroup ( 'group' , 'consumer' , { key : 'key' , id : '>' } ) ,
72
+ client . xAutoClaim ( 'key' , 'group' , 'consumer' , 0 , '0-0' )
73
+ ] ) ;
74
+
75
+ assert . deepEqual ( reply , {
76
+ nextId : '0-0' ,
77
+ messages : testUtils . isVersionGreaterThan ( [ 7 , 0 ] ) ? [ {
78
+ id,
79
+ message : Object . create ( null , {
80
+ bar : {
81
+ value : 'baz' ,
82
+ configurable : true ,
83
+ enumerable : true
84
+ }
85
+ } )
86
+ } ] : [ null , {
87
+ id,
88
+ message : Object . create ( null , {
89
+ bar : {
90
+ value : 'baz' ,
91
+ configurable : true ,
92
+ enumerable : true
93
+ }
94
+ } )
95
+ } ]
96
+ } ) ;
41
97
} , GLOBAL . SERVERS . OPEN ) ;
42
98
} ) ;
0 commit comments