@@ -33,7 +33,7 @@ import { CloudFormationTemplateRegistry } from '../../../shared/fs/templateRegis
3333import { getTestWindow } from '../vscode/window'
3434import { CancellationError } from '../../../shared/utilities/timeoutUtils'
3535
36- describe ( 'BuildWizard' , async function ( ) {
36+ describe ( 'SAM BuildWizard' , async function ( ) {
3737 const createTester = async ( params ?: Partial < BuildParams > , arg ?: TreeNode | undefined ) =>
3838 createWizardTester ( new BuildWizard ( { ...params } , await globals . templateRegistry , arg ) )
3939
@@ -82,154 +82,156 @@ describe('BuildWizard', async function () {
8282 } )
8383} )
8484
85- describe ( 'getBuildFlags' , ( ) => {
86- let sandbox : sinon . SinonSandbox
87- let projectRoot : vscode . Uri
88- const defaultFlags : string [ ] = [ '--cached' , '--parallel' , '--save-params' , '--use-container' ]
89- let quickPickItems : DataQuickPickItem < string > [ ]
85+ describe ( 'SAM build helper functions' , ( ) => {
86+ describe ( 'getBuildFlags' , ( ) => {
87+ let sandbox : sinon . SinonSandbox
88+ let projectRoot : vscode . Uri
89+ const defaultFlags : string [ ] = [ '--cached' , '--parallel' , '--save-params' , '--use-container' ]
90+ let quickPickItems : DataQuickPickItem < string > [ ]
9091
91- beforeEach ( ( ) => {
92- sandbox = sinon . createSandbox ( )
93- projectRoot = vscode . Uri . parse ( 'file:///path/to/project' )
94- quickPickItems = [
95- {
96- label : 'Beta features' ,
97- data : '--beta-features' ,
98- description : 'Enable beta features' ,
99- } ,
100- {
101- label : 'Build in source' ,
102- data : '--build-in-source' ,
103- description : 'Opts in to build project in the source folder' ,
104- } ,
105- {
106- label : 'Cached' ,
107- data : '--cached' ,
108- description : 'Reuse build artifacts that have not changed from previous builds' ,
109- } ,
110- {
111- label : 'Debug' ,
112- data : '--debug' ,
113- description : 'Turn on debug logging to print debug messages and display timestamps' ,
114- } ,
115- {
116- label : 'Parallel' ,
117- data : '--parallel' ,
118- description : 'Enable parallel builds for AWS SAM template functions and layers' ,
119- } ,
120- {
121- label : 'Skip prepare infra' ,
122- data : '--skip-prepare-infra' ,
123- description : 'Skip preparation stage when there are no infrastructure changes' ,
124- } ,
125- {
126- label : 'Skip pull image' ,
127- data : '--skip-pull-image' ,
128- description : 'Skip pulling down the latest Docker image for Lambda runtime' ,
129- } ,
130- {
131- label : 'Use container' ,
132- data : '--use-container' ,
133- description : 'Build functions with an AWS Lambda-like container' ,
134- } ,
135- {
136- label : 'Save parameters' ,
137- data : '--save-params' ,
138- description : 'Save to samconfig.toml as default parameters' ,
139- } ,
140- ]
141- } )
92+ beforeEach ( ( ) => {
93+ sandbox = sinon . createSandbox ( )
94+ projectRoot = vscode . Uri . parse ( 'file:///path/to/project' )
95+ quickPickItems = [
96+ {
97+ label : 'Beta features' ,
98+ data : '--beta-features' ,
99+ description : 'Enable beta features' ,
100+ } ,
101+ {
102+ label : 'Build in source' ,
103+ data : '--build-in-source' ,
104+ description : 'Opts in to build project in the source folder' ,
105+ } ,
106+ {
107+ label : 'Cached' ,
108+ data : '--cached' ,
109+ description : 'Reuse build artifacts that have not changed from previous builds' ,
110+ } ,
111+ {
112+ label : 'Debug' ,
113+ data : '--debug' ,
114+ description : 'Turn on debug logging to print debug messages and display timestamps' ,
115+ } ,
116+ {
117+ label : 'Parallel' ,
118+ data : '--parallel' ,
119+ description : 'Enable parallel builds for AWS SAM template functions and layers' ,
120+ } ,
121+ {
122+ label : 'Skip prepare infra' ,
123+ data : '--skip-prepare-infra' ,
124+ description : 'Skip preparation stage when there are no infrastructure changes' ,
125+ } ,
126+ {
127+ label : 'Skip pull image' ,
128+ data : '--skip-pull-image' ,
129+ description : 'Skip pulling down the latest Docker image for Lambda runtime' ,
130+ } ,
131+ {
132+ label : 'Use container' ,
133+ data : '--use-container' ,
134+ description : 'Build functions with an AWS Lambda-like container' ,
135+ } ,
136+ {
137+ label : 'Save parameters' ,
138+ data : '--save-params' ,
139+ description : 'Save to samconfig.toml as default parameters' ,
140+ } ,
141+ ]
142+ } )
142143
143- afterEach ( ( ) => {
144- sandbox . restore ( ) // Restore all stubs after each test
145- } )
144+ afterEach ( ( ) => {
145+ sandbox . restore ( ) // Restore all stubs after each test
146+ } )
146147
147- it ( 'should return flags from buildFlagsPrompter when paramsSource is Specify' , async ( ) => {
148- PrompterTester . init ( )
149- . handleQuickPick ( 'Select build flags' , async ( picker ) => {
150- await picker . untilReady ( )
151- assert . strictEqual ( picker . items . length , 9 )
152- assert . strictEqual ( picker . title , 'Select build flags' )
153- assert . deepStrictEqual ( picker . items , quickPickItems )
154- const betaFeatures = picker . items [ 0 ]
155- const buildInSource = picker . items [ 1 ]
156- const cached = picker . items [ 2 ]
157- assert . strictEqual ( betaFeatures . data , '--beta-features' )
158- assert . strictEqual ( buildInSource . data , '--build-in-source' )
159- assert . strictEqual ( cached . data , '--cached' )
160- const acceptedItems = [ betaFeatures , buildInSource , cached ]
161- picker . acceptItems ( ...acceptedItems )
162- } )
163- . build ( )
148+ it ( 'should return flags from buildFlagsPrompter when paramsSource is Specify' , async ( ) => {
149+ PrompterTester . init ( )
150+ . handleQuickPick ( 'Select build flags' , async ( picker ) => {
151+ await picker . untilReady ( )
152+ assert . strictEqual ( picker . items . length , 9 )
153+ assert . strictEqual ( picker . title , 'Select build flags' )
154+ assert . deepStrictEqual ( picker . items , quickPickItems )
155+ const betaFeatures = picker . items [ 0 ]
156+ const buildInSource = picker . items [ 1 ]
157+ const cached = picker . items [ 2 ]
158+ assert . strictEqual ( betaFeatures . data , '--beta-features' )
159+ assert . strictEqual ( buildInSource . data , '--build-in-source' )
160+ assert . strictEqual ( cached . data , '--cached' )
161+ const acceptedItems = [ betaFeatures , buildInSource , cached ]
162+ picker . acceptItems ( ...acceptedItems )
163+ } )
164+ . build ( )
164165
165- const flags = await createMultiPick ( quickPickItems , {
166- title : 'Select build flags' ,
167- ignoreFocusOut : true ,
168- } ) . prompt ( )
166+ const flags = await createMultiPick ( quickPickItems , {
167+ title : 'Select build flags' ,
168+ ignoreFocusOut : true ,
169+ } ) . prompt ( )
169170
170- assert . deepStrictEqual ( flags , JSON . stringify ( [ '--beta-features' , '--build-in-source' , '--cached' ] ) )
171- } )
171+ assert . deepStrictEqual ( flags , JSON . stringify ( [ '--beta-features' , '--build-in-source' , '--cached' ] ) )
172+ } )
172173
173- it ( 'should return config file flag when paramsSource is SamConfig' , async ( ) => {
174- const mockConfigFileUri = vscode . Uri . parse ( 'file:///path/to/samconfig.toml' )
175- const getConfigFileUriStub = sandbox . stub ( ) . resolves ( mockConfigFileUri )
176- sandbox . stub ( config , 'getConfigFileUri' ) . callsFake ( getConfigFileUriStub )
174+ it ( 'should return config file flag when paramsSource is SamConfig' , async ( ) => {
175+ const mockConfigFileUri = vscode . Uri . parse ( 'file:///path/to/samconfig.toml' )
176+ const getConfigFileUriStub = sandbox . stub ( ) . resolves ( mockConfigFileUri )
177+ sandbox . stub ( config , 'getConfigFileUri' ) . callsFake ( getConfigFileUriStub )
177178
178- const flags = await getBuildFlags ( ParamsSource . SamConfig , projectRoot , defaultFlags )
179- assert . deepStrictEqual ( flags , [ '--config-file' , mockConfigFileUri . fsPath ] )
180- } )
179+ const flags = await getBuildFlags ( ParamsSource . SamConfig , projectRoot , defaultFlags )
180+ assert . deepStrictEqual ( flags , [ '--config-file' , mockConfigFileUri . fsPath ] )
181+ } )
181182
182- it ( 'should return default flags if getConfigFileUri throws an error' , async ( ) => {
183- const getConfigFileUriStub = sinon . stub ( ) . rejects ( new Error ( 'Config file not found' ) )
184- sandbox . stub ( config , 'getConfigFileUri' ) . callsFake ( getConfigFileUriStub )
183+ it ( 'should return default flags if getConfigFileUri throws an error' , async ( ) => {
184+ const getConfigFileUriStub = sinon . stub ( ) . rejects ( new Error ( 'Config file not found' ) )
185+ sandbox . stub ( config , 'getConfigFileUri' ) . callsFake ( getConfigFileUriStub )
185186
186- const flags = await getBuildFlags ( ParamsSource . SamConfig , projectRoot , defaultFlags )
187- assert . deepStrictEqual ( flags , defaultFlags )
187+ const flags = await getBuildFlags ( ParamsSource . SamConfig , projectRoot , defaultFlags )
188+ assert . deepStrictEqual ( flags , defaultFlags )
189+ } )
188190 } )
189- } )
190191
191- describe ( 'createParamsSourcePrompter' , ( ) => {
192- it ( 'should return a prompter with the correct items with no valid samconfig' , ( ) => {
193- const expectedItems : DataQuickPickItem < ParamsSource > [ ] = [
194- {
195- label : 'Specify build flags' ,
196- data : ParamsSource . Specify ,
197- } ,
198- {
199- label : 'Use default values' ,
200- data : ParamsSource . DefaultValues ,
201- description : 'cached = true, parallel = true, use_container = true' ,
202- } ,
203- ]
204- const prompter = createParamsSourcePrompter ( false )
205- const quickPick = prompter . quickPick
206- assert . strictEqual ( quickPick . title , 'Specify parameter source for build' )
207- assert . strictEqual ( quickPick . placeholder , 'Select configuration options for sam build' )
208- assert . strictEqual ( quickPick . items . length , 2 )
209- assert . deepStrictEqual ( quickPick . items , expectedItems )
210- } )
192+ describe ( 'createParamsSourcePrompter' , ( ) => {
193+ it ( 'should return a prompter with the correct items with no valid samconfig' , ( ) => {
194+ const expectedItems : DataQuickPickItem < ParamsSource > [ ] = [
195+ {
196+ label : 'Specify build flags' ,
197+ data : ParamsSource . Specify ,
198+ } ,
199+ {
200+ label : 'Use default values' ,
201+ data : ParamsSource . DefaultValues ,
202+ description : 'cached = true, parallel = true, use_container = true' ,
203+ } ,
204+ ]
205+ const prompter = createParamsSourcePrompter ( false )
206+ const quickPick = prompter . quickPick
207+ assert . strictEqual ( quickPick . title , 'Specify parameter source for build' )
208+ assert . strictEqual ( quickPick . placeholder , 'Select configuration options for sam build' )
209+ assert . strictEqual ( quickPick . items . length , 2 )
210+ assert . deepStrictEqual ( quickPick . items , expectedItems )
211+ } )
211212
212- it ( 'should return a prompter with the correct items with valid samconfig' , ( ) => {
213- const expectedItems : DataQuickPickItem < ParamsSource > [ ] = [
214- {
215- label : 'Specify build flags' ,
216- data : ParamsSource . Specify ,
217- } ,
218- {
219- label : 'Use default values from samconfig' ,
220- data : ParamsSource . SamConfig ,
221- } ,
222- ]
223- const prompter = createParamsSourcePrompter ( true )
224- const quickPick = prompter . quickPick
225- assert . strictEqual ( quickPick . title , 'Specify parameter source for build' )
226- assert . strictEqual ( quickPick . placeholder , 'Select configuration options for sam build' )
227- assert . strictEqual ( quickPick . items . length , 2 )
228- assert . deepStrictEqual ( quickPick . items , expectedItems )
213+ it ( 'should return a prompter with the correct items with valid samconfig' , ( ) => {
214+ const expectedItems : DataQuickPickItem < ParamsSource > [ ] = [
215+ {
216+ label : 'Specify build flags' ,
217+ data : ParamsSource . Specify ,
218+ } ,
219+ {
220+ label : 'Use default values from samconfig' ,
221+ data : ParamsSource . SamConfig ,
222+ } ,
223+ ]
224+ const prompter = createParamsSourcePrompter ( true )
225+ const quickPick = prompter . quickPick
226+ assert . strictEqual ( quickPick . title , 'Specify parameter source for build' )
227+ assert . strictEqual ( quickPick . placeholder , 'Select configuration options for sam build' )
228+ assert . strictEqual ( quickPick . items . length , 2 )
229+ assert . deepStrictEqual ( quickPick . items , expectedItems )
230+ } )
229231 } )
230232} )
231233
232- describe ( 'SAM Build ' , ( ) => {
234+ describe ( 'SAM runBuild ' , ( ) => {
233235 let sandbox : sinon . SinonSandbox
234236 let testFolder : TestFolder
235237 let projectRoot : vscode . Uri
0 commit comments