@@ -68,6 +68,10 @@ describe('SamCliLocalInvokeInvocation', async function () {
6868 // `extraArgs` are appended to the end.
6969 assert . strictEqual ( invokeArgs . args [ 10 ] , '--build-dir' )
7070 assert . strictEqual ( invokeArgs . args [ 11 ] , 'my/build/dir/' )
71+
72+ // 'runtime' is the last argument.
73+ assert . strictEqual ( invokeArgs . args [ invokeArgs . args . length - 2 ] , '--runtime' )
74+ assert . strictEqual ( invokeArgs . args [ invokeArgs . args . length - 1 ] , 'python3.10' )
7175 }
7276 )
7377
@@ -78,6 +82,7 @@ describe('SamCliLocalInvokeInvocation', async function () {
7882 environmentVariablePath : nonRelevantArg ,
7983 invoker : taskInvoker ,
8084 extraArgs : [ '--build-dir' , 'my/build/dir/' ] ,
85+ runtime : 'python3.10' ,
8186 } ) . execute ( )
8287 } )
8388
@@ -302,4 +307,39 @@ describe('SamCliLocalInvokeInvocation', async function () {
302307 invoker : taskInvoker ,
303308 } ) . execute ( )
304309 } )
310+
311+ it ( 'Passes runtime to sam cli' , async function ( ) {
312+ const runtime = 'python3.10'
313+
314+ const taskInvoker : SamLocalInvokeCommand = new TestSamLocalInvokeCommand (
315+ ( invokeArgs : SamLocalInvokeCommandArgs ) => {
316+ assertArgsContainArgument ( invokeArgs . args , '--runtime' , runtime )
317+ }
318+ )
319+
320+ await new SamCliLocalInvokeInvocation ( {
321+ templateResourceName : nonRelevantArg ,
322+ templatePath : placeholderTemplateFile ,
323+ eventPath : placeholderEventFile ,
324+ environmentVariablePath : nonRelevantArg ,
325+ invoker : taskInvoker ,
326+ runtime : runtime ,
327+ } ) . execute ( )
328+ } )
329+
330+ it ( 'Does not pass runtime to sam cli when undefined' , async function ( ) {
331+ const taskInvoker : SamLocalInvokeCommand = new TestSamLocalInvokeCommand (
332+ ( invokeArgs : SamLocalInvokeCommandArgs ) => {
333+ assertArgNotPresent ( invokeArgs . args , '--runtime' )
334+ }
335+ )
336+
337+ await new SamCliLocalInvokeInvocation ( {
338+ templateResourceName : nonRelevantArg ,
339+ templatePath : placeholderTemplateFile ,
340+ eventPath : placeholderEventFile ,
341+ environmentVariablePath : nonRelevantArg ,
342+ invoker : taskInvoker ,
343+ } ) . execute ( )
344+ } )
305345} )
0 commit comments