1
- /**
2
- * Test idempotency decorator
3
- *
4
- * @group e2e/idempotency/decorator
5
- */
6
1
import { createHash } from 'node:crypto' ;
7
2
import { join } from 'node:path' ;
8
3
import {
@@ -14,6 +9,7 @@ import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
14
9
import { ScanCommand } from '@aws-sdk/lib-dynamodb' ;
15
10
import { Duration } from 'aws-cdk-lib' ;
16
11
import { AttributeType } from 'aws-cdk-lib/aws-dynamodb' ;
12
+ import { afterAll , beforeAll , describe , expect , it } from 'vitest' ;
17
13
import { IdempotencyTestNodejsFunctionAndDynamoTable } from '../helpers/resources.js' ;
18
14
import {
19
15
RESOURCE_NAME_PREFIX ,
@@ -166,8 +162,8 @@ describe('Idempotency e2e test decorator, default settings', () => {
166
162
tableNameDataIndex = testStack . findAndGetStackOutputValue ( 'dataIndexTable' ) ;
167
163
} , SETUP_TIMEOUT ) ;
168
164
169
- test (
170
- 'when called twice with the same payload, it returns the same result and runs the handler once' ,
165
+ it (
166
+ 'returns the same result and runs the handler once when called multiple times ' ,
171
167
async ( ) => {
172
168
const payload = { foo : 'bar' } ;
173
169
@@ -208,8 +204,8 @@ describe('Idempotency e2e test decorator, default settings', () => {
208
204
TEST_CASE_TIMEOUT
209
205
) ;
210
206
211
- test (
212
- 'when called twice in parallel, the handler is called only once ' ,
207
+ it (
208
+ 'handles parallel invocations correctly ' ,
213
209
async ( ) => {
214
210
const payload = { foo : 'bar' } ;
215
211
const payloadHash = createHash ( 'md5' )
@@ -256,8 +252,8 @@ describe('Idempotency e2e test decorator, default settings', () => {
256
252
TEST_CASE_TIMEOUT
257
253
) ;
258
254
259
- test (
260
- 'when the function times out, the second request is processed correctly by the handler ' ,
255
+ it (
256
+ 'recovers from a timed out request and processes the next one ' ,
261
257
async ( ) => {
262
258
const payload = { foo : 'bar' } ;
263
259
const payloadHash = createHash ( 'md5' )
@@ -311,8 +307,8 @@ describe('Idempotency e2e test decorator, default settings', () => {
311
307
TEST_CASE_TIMEOUT
312
308
) ;
313
309
314
- test (
315
- 'when the idempotency record is expired, the second request is processed correctly by the handler ' ,
310
+ it (
311
+ 'recovers from an expired idempotency record and processes the next request' ,
316
312
async ( ) => {
317
313
const payload = {
318
314
foo : 'baz' ,
@@ -385,8 +381,8 @@ describe('Idempotency e2e test decorator, default settings', () => {
385
381
TEST_CASE_TIMEOUT
386
382
) ;
387
383
388
- test (
389
- 'when called with customized function wrapper, it creates ddb entry with custom attributes' ,
384
+ it (
385
+ 'uses the provided custom idempotency record attributes' ,
390
386
async ( ) => {
391
387
const payload = { foo : 'bar' } ;
392
388
const payloadHash = createHash ( 'md5' )
@@ -425,8 +421,8 @@ describe('Idempotency e2e test decorator, default settings', () => {
425
421
TEST_CASE_TIMEOUT
426
422
) ;
427
423
428
- test (
429
- 'when called twice for with different payload using data index arugment, it returns the same result and runs the handler once ' ,
424
+ it (
425
+ 'takes the data index argument into account when making the function idempotent ' ,
430
426
async ( ) => {
431
427
const payload = [ { id : '1234' } , { id : '5678' } ] ;
432
428
const payloadHash = createHash ( 'md5' )
0 commit comments