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