@@ -2,6 +2,7 @@ import { strict as assert } from 'node:assert';
2
2
import testUtils , { GLOBAL } from '../test-utils' ;
3
3
import XTRIM from './XTRIM' ;
4
4
import { parseArgs } from './generic-transformers' ;
5
+ import { STREAM_DELETION_POLICY } from './common-stream.types' ;
5
6
6
7
describe ( 'XTRIM' , ( ) => {
7
8
describe ( 'transformArguments' , ( ) => {
@@ -12,6 +13,13 @@ describe('XTRIM', () => {
12
13
) ;
13
14
} ) ;
14
15
16
+ it ( 'simple - MINID' , ( ) => {
17
+ assert . deepEqual (
18
+ parseArgs ( XTRIM , 'key' , 'MINID' , 123 ) ,
19
+ [ 'XTRIM' , 'key' , 'MINID' , '123' ]
20
+ ) ;
21
+ } ) ;
22
+
15
23
it ( 'with strategyModifier' , ( ) => {
16
24
assert . deepEqual (
17
25
parseArgs ( XTRIM , 'key' , 'MAXLEN' , 1 , {
@@ -39,15 +47,96 @@ describe('XTRIM', () => {
39
47
[ 'XTRIM' , 'key' , 'MAXLEN' , '=' , '1' , 'LIMIT' , '1' ]
40
48
) ;
41
49
} ) ;
50
+
51
+ it ( 'with policy' , ( ) => {
52
+ assert . deepEqual (
53
+ parseArgs ( XTRIM , 'key' , 'MAXLEN' , 1 , {
54
+ policy : STREAM_DELETION_POLICY . DELREF
55
+ } ) ,
56
+ [ 'XTRIM' , 'key' , 'MAXLEN' , '1' , 'DELREF' ]
57
+ ) ;
58
+ } ) ;
59
+
60
+ it ( 'with all options' , ( ) => {
61
+ assert . deepEqual (
62
+ parseArgs ( XTRIM , 'key' , 'MAXLEN' , 1 , {
63
+ strategyModifier : '~' ,
64
+ LIMIT : 100 ,
65
+ policy : STREAM_DELETION_POLICY . ACKED
66
+ } ) ,
67
+ [ 'XTRIM' , 'key' , 'MAXLEN' , '~' , '1' , 'LIMIT' , '100' , 'ACKED' ]
68
+ ) ;
69
+ } ) ;
70
+ } ) ;
71
+
72
+ testUtils . testAll ( 'xTrim with MAXLEN' , async client => {
73
+ assert . equal (
74
+ typeof await client . xTrim ( 'key' , 'MAXLEN' , 1 ) ,
75
+ 'number'
76
+ ) ;
77
+ } , {
78
+ client : GLOBAL . SERVERS . OPEN ,
79
+ cluster : GLOBAL . CLUSTERS . OPEN ,
42
80
} ) ;
43
81
44
- testUtils . testAll ( 'xTrim' , async client => {
82
+ testUtils . testAll ( 'xTrim with MINID ' , async client => {
45
83
assert . equal (
46
- await client . xTrim ( 'key' , 'MAXLEN ' , 1 ) ,
47
- 0
84
+ typeof await client . xTrim ( 'key' , 'MINID ' , 1 ) ,
85
+ 'number'
48
86
) ;
49
87
} , {
50
88
client : GLOBAL . SERVERS . OPEN ,
51
89
cluster : GLOBAL . CLUSTERS . OPEN ,
52
90
} ) ;
91
+
92
+ testUtils . testAll (
93
+ 'xTrim with LIMIT' ,
94
+ async ( client ) => {
95
+ assert . equal (
96
+ typeof await client . xTrim ( '{tag}key' , 'MAXLEN' , 1000 , {
97
+ strategyModifier : '~' ,
98
+ LIMIT : 10
99
+ } ) ,
100
+ 'number'
101
+ ) ;
102
+ } ,
103
+ {
104
+ client : GLOBAL . SERVERS . OPEN ,
105
+ cluster : GLOBAL . CLUSTERS . OPEN ,
106
+ }
107
+ ) ;
108
+
109
+ testUtils . testAll (
110
+ 'xTrim with policy' ,
111
+ async ( client ) => {
112
+ assert . equal (
113
+ typeof await client . xTrim ( '{tag}key' , 'MAXLEN' , 0 , {
114
+ policy : STREAM_DELETION_POLICY . DELREF
115
+ } ) ,
116
+ 'number'
117
+ ) ;
118
+ } ,
119
+ {
120
+ client : { ...GLOBAL . SERVERS . OPEN , minimumDockerVersion : [ 8 , 2 ] } ,
121
+ cluster : { ...GLOBAL . CLUSTERS . OPEN , minimumDockerVersion : [ 8 , 2 ] } ,
122
+ }
123
+ ) ;
124
+
125
+ testUtils . testAll (
126
+ 'xTrim with all options' ,
127
+ async ( client ) => {
128
+ assert . equal (
129
+ typeof await client . xTrim ( '{tag}key' , 'MINID' , 0 , {
130
+ strategyModifier : '~' ,
131
+ LIMIT : 10 ,
132
+ policy : STREAM_DELETION_POLICY . KEEPREF
133
+ } ) ,
134
+ 'number'
135
+ ) ;
136
+ } ,
137
+ {
138
+ client : { ...GLOBAL . SERVERS . OPEN , minimumDockerVersion : [ 8 , 2 ] } ,
139
+ cluster : { ...GLOBAL . CLUSTERS . OPEN , minimumDockerVersion : [ 8 , 2 ] } ,
140
+ }
141
+ ) ;
53
142
} ) ;
0 commit comments