@@ -12,6 +12,8 @@ const execAsync = promisify(exec);
1212
1313const resourcesPath = path . resolve ( __dirname , 'resources' ) ;
1414
15+ const TEST_TIMEOUT = Number ( process . env . TEST_TIMEOUT ?? "999999" ) ;
16+
1517/**
1618 * Determine the optimal Lambda Function architecture based on the Docker host's CPU
1719 * architecture. This allows GHA runners to work without slow QEMU Arm emulation.
@@ -56,43 +58,43 @@ beforeEach(async () => {
5658 process . env . CDK_OUTDIR = await fs . mkdtemp (
5759 path . join ( os . tmpdir ( ) , 'uv-python-lambda-test-' ) ,
5860 ) ;
59- } , 999999 ) ;
61+ } , TEST_TIMEOUT ) ;
6062
6163afterEach ( async ( ) => {
6264 if ( process . env . CDK_OUTDIR ) {
6365 await fs . rm ( process . env . CDK_OUTDIR , { recursive : true } ) ;
6466 }
6567 process . env = OLD_ENV ;
66- } , 999999 ) ;
68+ } , TEST_TIMEOUT ) ;
6769
68- // test('Create a function from basic_app', async () => {
69- // const { app, stack } = await createStack();
70+ test ( 'Create a function from basic_app' , async ( ) => {
71+ const { app, stack } = await createStack ( ) ;
7072
71- // new PythonFunction(stack, 'basic_app', {
72- // rootDir: path.join(resourcesPath, 'basic_app'),
73- // index: 'handler.py',
74- // handler: 'lambda_handler',
75- // runtime: Runtime.PYTHON_3_12,
76- // architecture: await getDockerHostArch(),
77- // });
73+ new PythonFunction ( stack , 'basic_app' , {
74+ rootDir : path . join ( resourcesPath , 'basic_app' ) ,
75+ index : 'handler.py' ,
76+ handler : 'lambda_handler' ,
77+ runtime : Runtime . PYTHON_3_12 ,
78+ architecture : await getDockerHostArch ( ) ,
79+ } ) ;
7880
79- // const template = Template.fromStack(stack);
81+ const template = Template . fromStack ( stack ) ;
8082
81- // template.hasResourceProperties('AWS::Lambda::Function', {
82- // Handler: 'handler.lambda_handler',
83- // Runtime: 'python3.12',
84- // Code: {
85- // S3Bucket: Match.anyValue(),
86- // S3Key: Match.anyValue(),
87- // },
88- // });
89- // const functions = Object.values(
90- // template.findResources('AWS::Lambda::Function'),
91- // );
92- // expect(functions).toHaveLength(1);
93- // const contents = await getFunctionAssetContents(functions[0], app);
94- // expect(contents).toContain('handler.py');
95- // });
83+ template . hasResourceProperties ( 'AWS::Lambda::Function' , {
84+ Handler : 'handler.lambda_handler' ,
85+ Runtime : 'python3.12' ,
86+ Code : {
87+ S3Bucket : Match . anyValue ( ) ,
88+ S3Key : Match . anyValue ( ) ,
89+ } ,
90+ } ) ;
91+ const functions = Object . values (
92+ template . findResources ( 'AWS::Lambda::Function' ) ,
93+ ) ;
94+ expect ( functions ) . toHaveLength ( 1 ) ;
95+ const contents = await getFunctionAssetContents ( functions [ 0 ] , app ) ;
96+ expect ( contents ) . toContain ( 'handler.py' ) ;
97+ } ) ;
9698
9799// test('Create a function from basic_app with no .py index extension', async () => {
98100// const { stack } = await createStack();
@@ -139,45 +141,43 @@ afterEach(async () => {
139141// bundlingSpy.mockRestore();
140142// });
141143
142- test ( 'Create a function with workspaces_app' , async ( ) => {
143- const { app, stack } = await createStack ( 'wstest' ) ;
144+ // test('Create a function with workspaces_app', async () => {
145+ // const { app, stack } = await createStack('wstest');
144146
145- new PythonFunction ( stack , 'workspaces_app' , {
146- rootDir : path . join ( resourcesPath , 'workspaces_app' ) ,
147- workspacePackage : 'app' ,
148- index : 'app_handler.py' ,
149- handler : 'handle_event' ,
150- runtime : Runtime . PYTHON_3_10 ,
151- architecture : await getDockerHostArch ( ) ,
152- } ) ;
147+ // new PythonFunction(stack, 'workspaces_app', {
148+ // rootDir: path.join(resourcesPath, 'workspaces_app'),
149+ // workspacePackage: 'app',
150+ // index: 'app_handler.py',
151+ // handler: 'handle_event',
152+ // runtime: Runtime.PYTHON_3_10,
153+ // architecture: await getDockerHostArch(),
154+ // });
153155
154- const template = Template . fromStack ( stack ) ;
156+ // const template = Template.fromStack(stack);
155157
156- template . hasResourceProperties ( 'AWS::Lambda::Function' , {
157- Handler : 'app_handler.handle_event' ,
158- Runtime : 'python3.10' ,
159- Code : {
160- S3Bucket : Match . anyValue ( ) ,
161- S3Key : Match . anyValue ( ) ,
162- } ,
163- } ) ;
158+ // template.hasResourceProperties('AWS::Lambda::Function', {
159+ // Handler: 'app_handler.handle_event',
160+ // Runtime: 'python3.10',
161+ // Code: {
162+ // S3Bucket: Match.anyValue(),
163+ // S3Key: Match.anyValue(),
164+ // },
165+ // });
164166
165- const functions = Object . values (
166- template . findResources ( 'AWS::Lambda::Function' ) ,
167- ) ;
168- expect ( functions ) . toHaveLength ( 1 ) ;
169- const contents = await getFunctionAssetContents ( functions [ 0 ] , app ) ;
170- for ( const entry of [
171- 'app' ,
172- 'common' ,
173- 'pydantic' ,
174- 'httpx' ,
175- '_common.pth' ,
176- 'app_handler.py' ,
177- ] ) {
178- expect ( contents ) . toContain ( entry ) ;
179- }
180- } , 999999 ) ;
167+ // const functions = Object.values(
168+ // template.findResources('AWS::Lambda::Function'),
169+ // );
170+ // expect(functions).toHaveLength(1);
171+ // const contents = await getFunctionAssetContents(functions[0], app);
172+ // for (const entry of [
173+ // 'common',
174+ // 'pydantic',
175+ // 'httpx',
176+ // 'app_handler.py',
177+ // ]) {
178+ // expect(contents).toContain(entry);
179+ // }
180+ // }, TEST_TIMEOUT);
181181
182182// biome-ignore lint/suspicious/noExplicitAny: <explanation>
183183async function getFunctionAssetContents ( functionResource : any , app : App ) {
0 commit comments