|
9 | 9 | * - AWS credentials for the frontend account must be configured |
10 | 10 | */ |
11 | 11 |
|
12 | | -import type { CloudFormationCustomResourceEvent, Context } from "aws-lambda"; |
13 | 12 | import { handler } from "./index.ts"; |
14 | 13 |
|
15 | 14 | process.env.EMAIL_DOMAIN = `abtesting.code.dev-gutools.co.uk`; |
16 | 15 |
|
17 | | -// Create a mock CloudFormation event |
18 | | -const mockEvent: CloudFormationCustomResourceEvent = { |
19 | | - RequestType: "Create", |
20 | | - ServiceToken: |
21 | | - "arn:aws:lambda:eu-west-1:123456789012:function:mock-function", |
22 | | - ResponseURL: |
23 | | - "https://cloudformation-custom-resource-response.s3.amazonaws.com/mock-url", |
24 | | - StackId: |
25 | | - "arn:aws:cloudformation:eu-west-1:123456789012:stack/mock-stack/mock-id", |
26 | | - RequestId: "mock-request-id", |
27 | | - LogicalResourceId: "MockResource", |
28 | | - ResourceType: "Custom::DictionaryDeployer", |
29 | | - ResourceProperties: { |
30 | | - ServiceToken: |
31 | | - "arn:aws:lambda:eu-west-1:123456789012:function:mock-function", |
32 | | - }, |
33 | | -}; |
34 | | - |
35 | | -// Create a mock Lambda context |
36 | | -const mockContext: Context = { |
37 | | - callbackWaitsForEmptyEventLoop: false, |
38 | | - functionName: "ab-testing-notification-lambda-local", |
39 | | - functionVersion: "$LATEST", |
40 | | - invokedFunctionArn: |
41 | | - "arn:aws:lambda:eu-west-1:123456789012:function:mock-function", |
42 | | - memoryLimitInMB: "512", |
43 | | - awsRequestId: "mock-request-id", |
44 | | - logGroupName: "/aws/lambda/ab-testing-notification-lambda-local", |
45 | | - logStreamName: "2025/11/19/[$LATEST]mock-stream", |
46 | | - getRemainingTimeInMillis: () => 300000, |
47 | | - done: () => {}, |
48 | | - fail: () => {}, |
49 | | - succeed: () => {}, |
50 | | -}; |
51 | | - |
52 | 16 | console.log(`Running lambda handler locally\n`); |
53 | 17 | console.log(`EMAIL_DOMAIN=${process.env.EMAIL_DOMAIN}\n`); |
54 | 18 |
|
55 | | -// Run the handler |
56 | | -// Cast to unknown then to the correct function type to work around typing issues |
57 | | -const runHandler = handler as unknown as ( |
58 | | - event: CloudFormationCustomResourceEvent, |
59 | | - context: Context, |
60 | | - callback: () => void, |
61 | | -) => Promise<void>; |
62 | | - |
63 | 19 | void (async () => { |
64 | 20 | try { |
65 | | - await runHandler(mockEvent, mockContext, () => {}); |
| 21 | + await handler(); |
66 | 22 | console.log("\n✅ Lambda handler completed successfully"); |
67 | 23 | process.exit(0); |
68 | 24 | } catch (error) { |
|
0 commit comments