@@ -71,6 +71,9 @@ describe("githubInputs", () => {
7171 expect ( test )
7272 . to . haveOwnProperty ( "buildspecOverride" )
7373 . and . to . equal ( undefined ) ;
74+ expect ( test ) . to . haveOwnProperty ( "computeTypeOverride" ) . and . to . equal ( undefined ) ;
75+ expect ( test ) . to . haveOwnProperty ( "environmentTypeOverride" ) . and . to . equal ( undefined ) ;
76+ expect ( test ) . to . haveOwnProperty ( "imageOverride" ) . and . to . equal ( undefined ) ;
7477 expect ( test ) . to . haveOwnProperty ( "envPassthrough" ) . and . to . deep . equal ( [ ] ) ;
7578 } ) ;
7679
@@ -120,6 +123,9 @@ describe("githubInputs", () => {
120123 expect ( test )
121124 . to . haveOwnProperty ( "buildspecOverride" )
122125 . and . to . equal ( undefined ) ;
126+ expect ( test ) . to . haveOwnProperty ( "computeTypeOverride" ) . and . to . equal ( undefined ) ;
127+ expect ( test ) . to . haveOwnProperty ( "environmentTypeOverride" ) . and . to . equal ( undefined ) ;
128+ expect ( test ) . to . haveOwnProperty ( "imageOverride" ) . and . to . equal ( undefined ) ;
123129 expect ( test ) . to . haveOwnProperty ( "envPassthrough" ) . and . to . deep . equal ( [ ] ) ;
124130 } ) ;
125131
@@ -173,6 +179,67 @@ describe("inputs2Parameters", () => {
173179 expect ( test )
174180 . to . haveOwnProperty ( "buildspecOverride" )
175181 . and . to . equal ( undefined ) ;
182+ expect ( test ) . to . haveOwnProperty ( "computeTypeOverride" ) . and . to . equal ( undefined ) ;
183+ expect ( test ) . to . haveOwnProperty ( "environmentTypeOverride" ) . and . to . equal ( undefined ) ;
184+ expect ( test ) . to . haveOwnProperty ( "imageOverride" ) . and . to . equal ( undefined ) ;
185+
186+ // I send everything that starts 'GITHUB_'
187+ expect ( test )
188+ . to . haveOwnProperty ( "environmentVariablesOverride" )
189+ . and . to . have . lengthOf . greaterThan ( 1 ) ;
190+
191+ const [ repoEnv ] = test . environmentVariablesOverride . filter (
192+ ( { name } ) => name === "GITHUB_REPOSITORY"
193+ ) ;
194+ expect ( repoEnv )
195+ . to . haveOwnProperty ( "name" )
196+ . and . to . equal ( "GITHUB_REPOSITORY" ) ;
197+ expect ( repoEnv ) . to . haveOwnProperty ( "value" ) . and . to . equal ( repoInfo ) ;
198+ expect ( repoEnv ) . to . haveOwnProperty ( "type" ) . and . to . equal ( "PLAINTEXT" ) ;
199+
200+ const [ shaEnv ] = test . environmentVariablesOverride . filter (
201+ ( { name } ) => name === "GITHUB_SHA"
202+ ) ;
203+ expect ( shaEnv ) . to . haveOwnProperty ( "name" ) . and . to . equal ( "GITHUB_SHA" ) ;
204+ expect ( shaEnv ) . to . haveOwnProperty ( "value" ) . and . to . equal ( sha ) ;
205+ expect ( shaEnv ) . to . haveOwnProperty ( "type" ) . and . to . equal ( "PLAINTEXT" ) ;
206+ } ) ;
207+
208+ it ( "build override parameters for codeBuild.startBuild" , ( ) => {
209+ // This is how GITHUB injects its input values.
210+ // It would be nice if there was an easy way to test this...
211+ process . env [ `INPUT_PROJECT-NAME` ] = projectName ;
212+ process . env [ `GITHUB_REPOSITORY` ] = repoInfo ;
213+ process . env [ `GITHUB_SHA` ] = sha ;
214+ const test = inputs2Parameters ( {
215+ projectName,
216+ sourceVersion : sha ,
217+ owner : "owner" ,
218+ repo : "repo" ,
219+ computeTypeOverride : "BUILD_GENERAL1_LARGE" ,
220+ environmentTypeOverride : "LINUX_CONTAINER" ,
221+ imageOverride : "111122223333.dkr.ecr.us-west-2.amazonaws.com/codebuild-docker-repo"
222+ } ) ;
223+ expect ( test ) . to . haveOwnProperty ( "projectName" ) . and . to . equal ( projectName ) ;
224+ expect ( test ) . to . haveOwnProperty ( "sourceVersion" ) . and . to . equal ( sha ) ;
225+ expect ( test )
226+ . to . haveOwnProperty ( "sourceTypeOverride" )
227+ . and . to . equal ( "GITHUB" ) ;
228+ expect ( test )
229+ . to . haveOwnProperty ( "sourceLocationOverride" )
230+ . and . to . equal ( `https://github.com/owner/repo.git` ) ;
231+ expect ( test )
232+ . to . haveOwnProperty ( "buildspecOverride" )
233+ . and . to . equal ( undefined ) ;
234+ expect ( test )
235+ . to . haveOwnProperty ( "computeTypeOverride" )
236+ . and . to . equal ( `BUILD_GENERAL1_LARGE` ) ;
237+ expect ( test )
238+ . to . haveOwnProperty ( "environmentTypeOverride" )
239+ . and . to . equal ( `LINUX_CONTAINER` ) ;
240+ expect ( test )
241+ . to . haveOwnProperty ( "imageOverride" )
242+ . and . to . equal ( `111122223333.dkr.ecr.us-west-2.amazonaws.com/codebuild-docker-repo` ) ;
176243
177244 // I send everything that starts 'GITHUB_'
178245 expect ( test )
0 commit comments