@@ -4,8 +4,8 @@ import { App, Stack } from 'aws-cdk-lib';
4
4
import { Template } from 'aws-cdk-lib/assertions' ;
5
5
import * as lambda from 'aws-cdk-lib/aws-lambda' ;
6
6
7
- void describe ( 'RestApiConstruct' , ( ) => {
8
- void it ( 'loads a function if the folder is specified' , ( ) => {
7
+ void describe ( 'RestApiConstruct Lambda Handling ' , ( ) => {
8
+ void it ( 'loads an existing local lambda function if the directory is specified' , ( ) => {
9
9
const app = new App ( ) ;
10
10
const stack = new Stack ( app ) ;
11
11
new RestApiConstruct ( stack , 'RestApiLambdaTest' , {
@@ -26,6 +26,30 @@ void describe('RestApiConstruct', () => {
26
26
Handler : 'index.handler' ,
27
27
} ) ;
28
28
} ) ;
29
+
30
+ void it ( 'creates a new lambda function if the code is specified' , ( ) => {
31
+ const app = new App ( ) ;
32
+ const stack = new Stack ( app ) ;
33
+ new RestApiConstruct ( stack , 'RestApiNewLambdaTest' , {
34
+ apiName : 'RestApiNewLambda' ,
35
+ apiProps : [
36
+ {
37
+ path : 'items' ,
38
+ routes : [ 'GET' ] ,
39
+ lambdaEntry : {
40
+ runtime : lambda . Runtime . NODEJS_22_X ,
41
+ source : {
42
+ code : "export const handler = () => {return 'Hello World! This is a new lambda function.';};" ,
43
+ } ,
44
+ } ,
45
+ } ,
46
+ ] ,
47
+ } ) ;
48
+ const template = Template . fromStack ( stack ) ;
49
+ template . hasResourceProperties ( 'AWS::Lambda::Function' , {
50
+ Handler : 'index.handler' ,
51
+ } ) ;
52
+ } ) ;
29
53
} ) ;
30
54
31
55
void describe ( 'RestApiConstruct' , ( ) => {
0 commit comments