@@ -137,9 +137,14 @@ describe(`Idempotency E2E tests, wrapper function usage`, () => {
137
137
) ;
138
138
// Since records 1 and 3 have the same payload, only 2 records should be created
139
139
expect ( idempotencyRecords ?. Items ?. length ) . toEqual ( 2 ) ;
140
- const idempotencyRecordsItems = idempotencyRecords . Items ?. sort ( ( a , b ) =>
141
- a . expiration > b . expiration ? 1 : - 1
142
- ) ;
140
+ const idempotencyRecordsItems = [
141
+ idempotencyRecords . Items ?. find (
142
+ ( record ) => record . id === `${ functionNameDefault } #${ payloadHashes [ 0 ] } `
143
+ ) ,
144
+ idempotencyRecords . Items ?. find (
145
+ ( record ) => record . id === `${ functionNameDefault } #${ payloadHashes [ 1 ] } `
146
+ ) ,
147
+ ] ;
143
148
144
149
expect ( idempotencyRecordsItems ?. [ 0 ] ) . toStrictEqual ( {
145
150
id : `${ functionNameDefault } #${ payloadHashes [ 0 ] } ` ,
@@ -197,14 +202,27 @@ describe(`Idempotency E2E tests, wrapper function usage`, () => {
197
202
) ;
198
203
/**
199
204
* Each record should have a corresponding entry in the persistence store,
200
- * if so then we sort the entries by expiry time and compare them to the
201
- * expected values. Expiry times should be in the same order as the
202
- * payload records.
205
+ * if so then we retrieve the records based on their custom IDs
206
+ * The records are retrieved in the same order as the payload records.
203
207
*/
204
208
expect ( idempotencyRecords . Items ?. length ) . toEqual ( 3 ) ;
205
- const idempotencyRecordsItems = idempotencyRecords . Items ?. sort ( ( a , b ) =>
206
- a . expiryAttr > b . expiryAttr ? 1 : - 1
207
- ) ;
209
+ const idempotencyRecordsItems = [
210
+ idempotencyRecords . Items ?. find (
211
+ ( record ) =>
212
+ record . customId ===
213
+ `${ functionNameCustomConfig } #${ payloadHashes [ 0 ] } `
214
+ ) ,
215
+ idempotencyRecords . Items ?. find (
216
+ ( record ) =>
217
+ record . customId ===
218
+ `${ functionNameCustomConfig } #${ payloadHashes [ 1 ] } `
219
+ ) ,
220
+ idempotencyRecords . Items ?. find (
221
+ ( record ) =>
222
+ record . customId ===
223
+ `${ functionNameCustomConfig } #${ payloadHashes [ 2 ] } `
224
+ ) ,
225
+ ] ;
208
226
209
227
expect ( idempotencyRecordsItems ?. [ 0 ] ) . toStrictEqual ( {
210
228
customId : `${ functionNameCustomConfig } #${ payloadHashes [ 0 ] } ` ,
0 commit comments