|
1 | 1 | import {App, assertions, Stack} from "aws-cdk-lib" |
2 | 2 | import {ManagedPolicy, PolicyStatement, Role} from "aws-cdk-lib/aws-iam" |
3 | 3 | import {LogGroup} from "aws-cdk-lib/aws-logs" |
4 | | -import {Function, LayerVersion} from "aws-cdk-lib/aws-lambda" |
| 4 | +import {Function, LayerVersion, Runtime} from "aws-cdk-lib/aws-lambda" |
5 | 5 | import {Template, Match} from "aws-cdk-lib/assertions" |
6 | 6 | import { |
7 | 7 | describe, |
@@ -114,7 +114,7 @@ describe("functionConstruct works correctly", () => { |
114 | 114 | test("it has the correct lambda", () => { |
115 | 115 | template.hasResourceProperties("AWS::Lambda::Function", { |
116 | 116 | Handler: "index.handler", |
117 | | - Runtime: "nodejs22.x", |
| 117 | + Runtime: "nodejs24.x", |
118 | 118 | FunctionName: "testLambda", |
119 | 119 | MemorySize: 256, |
120 | 120 | Architectures: ["x86_64"], |
@@ -166,7 +166,7 @@ describe("functionConstruct works correctly with environment variables", () => { |
166 | 166 |
|
167 | 167 | test("environment variables are added correctly", () => { |
168 | 168 | template.hasResourceProperties("AWS::Lambda::Function", { |
169 | | - Runtime: "nodejs22.x", |
| 169 | + Runtime: "nodejs24.x", |
170 | 170 | FunctionName: "testLambda", |
171 | 171 | Environment: {Variables: {foo: "bar"}} |
172 | 172 | }) |
@@ -249,7 +249,7 @@ describe("functionConstruct works correctly with additional layers", () => { |
249 | 249 | test("it has the correct layers added", () => { |
250 | 250 | template.hasResourceProperties("AWS::Lambda::Function", { |
251 | 251 | Handler: "index.handler", |
252 | | - Runtime: "nodejs22.x", |
| 252 | + Runtime: "nodejs24.x", |
253 | 253 | FunctionName: "testLambda", |
254 | 254 | MemorySize: 256, |
255 | 255 | Architectures: ["x86_64"], |
@@ -289,11 +289,42 @@ describe("functionConstruct works correctly with custom timeout", () => { |
289 | 289 | test("it has the correct timeout", () => { |
290 | 290 | template.hasResourceProperties("AWS::Lambda::Function", { |
291 | 291 | Handler: "index.handler", |
292 | | - Runtime: "nodejs22.x", |
| 292 | + Runtime: "nodejs24.x", |
293 | 293 | FunctionName: "testLambda", |
294 | 294 | MemorySize: 256, |
295 | 295 | Architectures: ["x86_64"], |
296 | 296 | Timeout: 120 |
297 | 297 | }) |
298 | 298 | }) |
299 | 299 | }) |
| 300 | + |
| 301 | +describe("functionConstruct works correctly with different runtime", () => { |
| 302 | + let stack: Stack |
| 303 | + let app: App |
| 304 | + let template: assertions.Template |
| 305 | + beforeAll(() => { |
| 306 | + app = new App() |
| 307 | + stack = new Stack(app, "lambdaConstructStack") |
| 308 | + new TypescriptLambdaFunction(stack, "dummyFunction", { |
| 309 | + functionName: "testLambda", |
| 310 | + additionalPolicies: [], |
| 311 | + packageBasePath: "packages/cdkConstructs", |
| 312 | + entryPoint: "tests/src/dummyLambda.ts", |
| 313 | + environmentVariables: {}, |
| 314 | + logRetentionInDays: 30, |
| 315 | + logLevel: "DEBUG", |
| 316 | + version: "1.0.0", |
| 317 | + commitId: "abcd1234", |
| 318 | + projectBaseDir: resolve(__dirname, "../../.."), |
| 319 | + runtime: Runtime.NODEJS_22_X |
| 320 | + }) |
| 321 | + template = Template.fromStack(stack) |
| 322 | + }) |
| 323 | + |
| 324 | + test("it has correct runtime", () => { |
| 325 | + template.hasResourceProperties("AWS::Lambda::Function", { |
| 326 | + Runtime: "nodejs22.x", |
| 327 | + FunctionName: "testLambda" |
| 328 | + }) |
| 329 | + }) |
| 330 | +}) |
0 commit comments