@@ -14,9 +14,10 @@ import {
1414import { ChildProcess } from '../../../../shared/utilities/processUtils'
1515import { assertArgIsPresent , assertArgNotPresent , assertArgsContainArgument } from './samCliTestUtils'
1616import { fs } from '../../../../shared'
17+ import { SamCliSettings } from '../../../../shared/sam/cli/samCliSettings'
1718import { isWin } from '../../../../shared/vscode/env'
18- // eslint-disable-next-line aws-toolkits/no-only-in-tests
19- describe . only ( 'SamCliLocalInvokeInvocation' , async function ( ) {
19+
20+ describe ( 'SamCliLocalInvokeInvocation' , async function ( ) {
2021 class TestSamLocalInvokeCommand implements SamLocalInvokeCommand {
2122 public constructor ( private readonly onInvoke : ( { ...params } : SamLocalInvokeCommandArgs ) => void ) { }
2223
@@ -31,6 +32,15 @@ describe.only('SamCliLocalInvokeInvocation', async function () {
3132 let placeholderEventFile : string
3233 const nonRelevantArg = 'arg is not of interest to this test'
3334
35+ before ( async function ( ) {
36+ // File system search on windows can take a while.
37+ if ( isWin ( ) ) {
38+ this . timeout ( 45000 )
39+ }
40+ // This will place the result in the cache allowing all tests to run under same conditions.
41+ await SamCliSettings . instance . getOrDetectSamCli ( )
42+ } )
43+
3444 beforeEach ( async function ( ) {
3545 tempFolder = await makeTemporaryToolkitFolder ( )
3646 placeholderTemplateFile = path . join ( tempFolder , 'template.yaml' )
@@ -42,40 +52,34 @@ describe.only('SamCliLocalInvokeInvocation', async function () {
4252 afterEach ( async function ( ) {
4353 await fs . delete ( tempFolder , { recursive : true } )
4454 } )
45- for ( const _ of Array . from ( { length : 1000 } , ( i ) => i ) ) {
46- // eslint-disable-next-line aws-toolkits/no-only-in-tests
47- it . only ( 'invokes `sam local` with args' , async function ( ) {
48- if ( isWin ( ) ) {
49- // TODO: insert 'C:\\Program Files\\Amazon\\AWSSAMCLI\\bin\\sam.cmd' into the cache.
50- this . timeout ( 45000 )
55+
56+ it ( 'invokes `sam local` with args' , async function ( ) {
57+ const taskInvoker : SamLocalInvokeCommand = new TestSamLocalInvokeCommand (
58+ ( invokeArgs : SamLocalInvokeCommandArgs ) => {
59+ assert . ok ( invokeArgs . args . length >= 2 , 'Expected args to be present' )
60+ assert . strictEqual ( invokeArgs . args [ 0 ] , 'local' )
61+ assert . strictEqual ( invokeArgs . args [ 1 ] , 'invoke' )
62+ // --debug is present because tests run with "debug" log-level. #1403
63+ assert . strictEqual ( invokeArgs . args [ 2 ] , '--debug' )
64+ assert . strictEqual ( invokeArgs . args [ 4 ] , '--template' )
65+ assert . strictEqual ( invokeArgs . args [ 6 ] , '--event' )
66+ assert . strictEqual ( invokeArgs . args [ 8 ] , '--env-vars' )
67+
68+ // `extraArgs` are appended to the end.
69+ assert . strictEqual ( invokeArgs . args [ 10 ] , '--build-dir' )
70+ assert . strictEqual ( invokeArgs . args [ 11 ] , 'my/build/dir/' )
5171 }
52- const taskInvoker : SamLocalInvokeCommand = new TestSamLocalInvokeCommand (
53- ( invokeArgs : SamLocalInvokeCommandArgs ) => {
54- assert . ok ( invokeArgs . args . length >= 2 , 'Expected args to be present' )
55- assert . strictEqual ( invokeArgs . args [ 0 ] , 'local' )
56- assert . strictEqual ( invokeArgs . args [ 1 ] , 'invoke' )
57- // --debug is present because tests run with "debug" log-level. #1403
58- assert . strictEqual ( invokeArgs . args [ 2 ] , '--debug' )
59- assert . strictEqual ( invokeArgs . args [ 4 ] , '--template' )
60- assert . strictEqual ( invokeArgs . args [ 6 ] , '--event' )
61- assert . strictEqual ( invokeArgs . args [ 8 ] , '--env-vars' )
62-
63- // `extraArgs` are appended to the end.
64- assert . strictEqual ( invokeArgs . args [ 10 ] , '--build-dir' )
65- assert . strictEqual ( invokeArgs . args [ 11 ] , 'my/build/dir/' )
66- }
67- )
68-
69- await new SamCliLocalInvokeInvocation ( {
70- templateResourceName : nonRelevantArg ,
71- templatePath : placeholderTemplateFile ,
72- eventPath : placeholderEventFile ,
73- environmentVariablePath : nonRelevantArg ,
74- invoker : taskInvoker ,
75- extraArgs : [ '--build-dir' , 'my/build/dir/' ] ,
76- } ) . execute ( )
77- } )
78- }
72+ )
73+
74+ await new SamCliLocalInvokeInvocation ( {
75+ templateResourceName : nonRelevantArg ,
76+ templatePath : placeholderTemplateFile ,
77+ eventPath : placeholderEventFile ,
78+ environmentVariablePath : nonRelevantArg ,
79+ invoker : taskInvoker ,
80+ extraArgs : [ '--build-dir' , 'my/build/dir/' ] ,
81+ } ) . execute ( )
82+ } )
7983
8084 it ( 'Passes template resource name to sam cli' , async function ( ) {
8185 const expectedResourceName = 'HelloWorldResource'
0 commit comments