|
| 1 | +import { createHash } from 'node:crypto'; |
| 2 | +import { join } from 'node:path'; |
| 3 | +import { |
| 4 | + TestInvocationLogs, |
| 5 | + TestStack, |
| 6 | + invokeFunction, |
| 7 | +} from '@aws-lambda-powertools/testing-utils'; |
1 | 8 | /**
|
2 | 9 | * Test idempotency decorator
|
3 | 10 | *
|
4 | 11 | * @group e2e/idempotency/decorator
|
5 | 12 | */
|
6 | 13 | import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
|
| 14 | +import { ScanCommand } from '@aws-sdk/lib-dynamodb'; |
| 15 | +import { Duration } from 'aws-cdk-lib'; |
| 16 | +import { AttributeType } from 'aws-cdk-lib/aws-dynamodb'; |
| 17 | +import { IdempotencyTestNodejsFunctionAndDynamoTable } from '../helpers/resources.js'; |
7 | 18 | import {
|
8 | 19 | RESOURCE_NAME_PREFIX,
|
9 | 20 | SETUP_TIMEOUT,
|
10 | 21 | TEARDOWN_TIMEOUT,
|
11 | 22 | TEST_CASE_TIMEOUT,
|
12 | 23 | } from './constants.js';
|
13 |
| -import { ScanCommand } from '@aws-sdk/lib-dynamodb'; |
14 |
| -import { createHash } from 'node:crypto'; |
15 |
| -import { |
16 |
| - invokeFunction, |
17 |
| - TestInvocationLogs, |
18 |
| - TestStack, |
19 |
| -} from '@aws-lambda-powertools/testing-utils'; |
20 |
| -import { IdempotencyTestNodejsFunctionAndDynamoTable } from '../helpers/resources.js'; |
21 |
| -import { join } from 'node:path'; |
22 |
| -import { Duration } from 'aws-cdk-lib'; |
23 |
| -import { AttributeType } from 'aws-cdk-lib/aws-dynamodb'; |
24 | 24 |
|
25 | 25 | const dynamoDBClient = new DynamoDBClient({});
|
26 | 26 |
|
@@ -289,9 +289,15 @@ describe('Idempotency e2e test decorator, default settings', () => {
|
289 | 289 | });
|
290 | 290 | expect(idempotencyRecord.Items?.[0].status).toEqual('COMPLETED');
|
291 | 291 |
|
292 |
| - // During the first invocation the handler should be called, so the logs should contain 1 log |
293 |
| - expect(functionLogs[0]).toHaveLength(2); |
294 |
| - expect(functionLogs[0][0]).toContain('Task timed out after'); |
| 292 | + try { |
| 293 | + // During the first invocation the handler should be called, so the logs should contain 1 log |
| 294 | + expect(functionLogs[0]).toHaveLength(2); |
| 295 | + expect(functionLogs[0][0]).toContain('Task timed out after'); |
| 296 | + } catch { |
| 297 | + // During the first invocation the function should timeout so the logs should not contain any log and the report log should contain a timeout message |
| 298 | + expect(functionLogs[0]).toHaveLength(0); |
| 299 | + expect(logs[0].getReportLog()).toMatch(/Status: timeout$/); |
| 300 | + } |
295 | 301 |
|
296 | 302 | expect(functionLogs[1]).toHaveLength(1);
|
297 | 303 | expect(TestInvocationLogs.parseFunctionLog(functionLogs[1][0])).toEqual(
|
|
0 commit comments