@@ -174,6 +174,44 @@ describe('Deploy to ECS', () => {
174174 expect ( mockEcsRegisterTaskDef ) . toHaveBeenNthCalledWith ( 1 , { family : 'task-def-family' } ) ;
175175 } ) ;
176176
177+ test ( 'cleans empty arrays out of the task definition contents' , async ( ) => {
178+ fs . readFileSync . mockImplementation ( ( pathInput , encoding ) => {
179+ if ( encoding != 'utf8' ) {
180+ throw new Error ( `Wrong encoding ${ encoding } ` ) ;
181+ }
182+
183+ return '{ "tags": [], "family": "task-def-family" }' ;
184+ } ) ;
185+
186+ await run ( ) ;
187+ expect ( core . setFailed ) . toHaveBeenCalledTimes ( 0 ) ;
188+ expect ( mockEcsRegisterTaskDef ) . toHaveBeenNthCalledWith ( 1 , { family : 'task-def-family' } ) ;
189+ } ) ;
190+
191+ test ( 'cleans empty strings and objects out of the task definition contents' , async ( ) => {
192+ fs . readFileSync . mockImplementation ( ( pathInput , encoding ) => {
193+ if ( encoding != 'utf8' ) {
194+ throw new Error ( `Wrong encoding ${ encoding } ` ) ;
195+ }
196+
197+ return '{ "memory": "", "containerDefinitions": [ { "name": "sample-container", "logConfiguration": {}, "repositoryCredentials": { "credentialsParameter": "" }, "cpu": 0, "essential": false } ], "requiresCompatibilities": [ "EC2" ], "family": "task-def-family" }' ;
198+ } ) ;
199+
200+ await run ( ) ;
201+ expect ( core . setFailed ) . toHaveBeenCalledTimes ( 0 ) ;
202+ expect ( mockEcsRegisterTaskDef ) . toHaveBeenNthCalledWith ( 1 , {
203+ family : 'task-def-family' ,
204+ containerDefinitions : [
205+ {
206+ name : 'sample-container' ,
207+ cpu : 0 ,
208+ essential : false
209+ }
210+ ] ,
211+ requiresCompatibilities : [ 'EC2' ]
212+ } ) ;
213+ } ) ;
214+
177215 test ( 'cleans invalid keys out of the task definition contents' , async ( ) => {
178216 fs . readFileSync . mockImplementation ( ( pathInput , encoding ) => {
179217 if ( encoding != 'utf8' ) {
0 commit comments