@@ -40,9 +40,17 @@ describe("idempotency-http-wrapper", () => {
40
40
} ,
41
41
} ) ;
42
42
const expectedTtl = String ( Math . floor ( mockNow / 1000 ) + ttl ) ;
43
+ const expectedValidTime = String ( Math . floor ( mockNow / 1000 ) - ttl ) ;
43
44
nock ( endpoint )
44
45
. post ( "/" , {
45
- ConditionExpression : "attribute_not_exists(messageId)" ,
46
+ ConditionExpression :
47
+ "attribute_not_exists(messageId) or (#ttl < :validTime)" ,
48
+ ExpressionAttributeNames : {
49
+ "#ttl" : "ttl" ,
50
+ } ,
51
+ ExpressionAttributeValues : {
52
+ ":validTime" : { N : expectedValidTime } ,
53
+ } ,
46
54
Item : { messageId : { S : requestId } , ttl : { N : expectedTtl } } ,
47
55
TableName : tableName ,
48
56
} )
@@ -92,9 +100,17 @@ describe("idempotency-http-wrapper", () => {
92
100
} ,
93
101
} ) ;
94
102
const expectedTtl = String ( Math . floor ( mockNow / 1000 ) + ttl ) ;
103
+ const expectedValidTime = String ( Math . floor ( mockNow / 1000 ) - ttl ) ;
95
104
nock ( endpoint )
96
105
. post ( "/" , {
97
- ConditionExpression : "attribute_not_exists(messageId)" ,
106
+ ConditionExpression :
107
+ "attribute_not_exists(messageId) or (#ttl < :validTime)" ,
108
+ ExpressionAttributeNames : {
109
+ "#ttl" : "ttl" ,
110
+ } ,
111
+ ExpressionAttributeValues : {
112
+ ":validTime" : { N : expectedValidTime } ,
113
+ } ,
98
114
Item : { messageId : { S : requestId } , ttl : { N : expectedTtl } } ,
99
115
TableName : tableName ,
100
116
} )
@@ -173,9 +189,17 @@ describe("idempotency-http-wrapper", () => {
173
189
} ,
174
190
} ) ;
175
191
const expectedTtl = String ( Math . floor ( mockNow / 1000 ) + defaultTTL ) ;
192
+ const expectedValidTime = String ( Math . floor ( mockNow / 1000 ) - defaultTTL ) ;
176
193
nock ( endpoint )
177
194
. post ( "/" , {
178
- ConditionExpression : "attribute_not_exists(messageId)" ,
195
+ ConditionExpression :
196
+ "attribute_not_exists(messageId) or (#ttl < :validTime)" ,
197
+ ExpressionAttributeNames : {
198
+ "#ttl" : "ttl" ,
199
+ } ,
200
+ ExpressionAttributeValues : {
201
+ ":validTime" : { N : expectedValidTime } ,
202
+ } ,
179
203
Item : { messageId : { S : requestId } , ttl : { N : expectedTtl } } ,
180
204
TableName : tableName ,
181
205
} )
@@ -223,9 +247,17 @@ describe("idempotency-http-wrapper", () => {
223
247
} ,
224
248
} ) ;
225
249
const expectedTtl = String ( Math . floor ( mockNow / 1000 ) + ttl ) ;
250
+ const expectedValidTime = String ( Math . floor ( mockNow / 1000 ) - ttl ) ;
226
251
nock ( endpoint )
227
252
. post ( "/" , {
228
- ConditionExpression : "attribute_not_exists(messageId)" ,
253
+ ConditionExpression :
254
+ "attribute_not_exists(messageId) or (#ttl < :validTime)" ,
255
+ ExpressionAttributeNames : {
256
+ "#ttl" : "ttl" ,
257
+ } ,
258
+ ExpressionAttributeValues : {
259
+ ":validTime" : { N : expectedValidTime } ,
260
+ } ,
229
261
Item : { messageId : { S : requestId } , ttl : { N : expectedTtl } } ,
230
262
TableName : tableName ,
231
263
} )
@@ -269,9 +301,17 @@ describe("idempotency-http-wrapper", () => {
269
301
} ,
270
302
} ) ;
271
303
const expectedTtl = String ( Math . floor ( mockNow / 1000 ) + ttl ) ;
304
+ const expectedValidTime = String ( Math . floor ( mockNow / 1000 ) - ttl ) ;
272
305
nock ( endpoint )
273
306
. post ( "/" , {
274
- ConditionExpression : "attribute_not_exists(messageId)" ,
307
+ ConditionExpression :
308
+ "attribute_not_exists(messageId) or (#ttl < :validTime)" ,
309
+ ExpressionAttributeNames : {
310
+ "#ttl" : "ttl" ,
311
+ } ,
312
+ ExpressionAttributeValues : {
313
+ ":validTime" : { N : expectedValidTime } ,
314
+ } ,
275
315
Item : { messageId : { S : requestId } , ttl : { N : expectedTtl } } ,
276
316
TableName : tableName ,
277
317
} )
@@ -316,9 +356,17 @@ describe("idempotency-http-wrapper", () => {
316
356
} ,
317
357
} ) ;
318
358
const expectedTtl = String ( Math . floor ( mockNow / 1000 ) + ttl ) ;
359
+ const expectedValidTime = String ( Math . floor ( mockNow / 1000 ) - ttl ) ;
319
360
nock ( endpoint )
320
361
. post ( "/" , {
321
- ConditionExpression : "attribute_not_exists(messageId)" ,
362
+ ConditionExpression :
363
+ "attribute_not_exists(messageId) or (#ttl < :validTime)" ,
364
+ ExpressionAttributeNames : {
365
+ "#ttl" : "ttl" ,
366
+ } ,
367
+ ExpressionAttributeValues : {
368
+ ":validTime" : { N : expectedValidTime } ,
369
+ } ,
322
370
Item : { messageId : { S : requestId } , ttl : { N : expectedTtl } } ,
323
371
TableName : tableName ,
324
372
} )
0 commit comments