@@ -103,4 +103,63 @@ test('update-pipeline - repository and branch success', async () => {
103103 await expect ( cli . action . stop . mock . calls [ 0 ] [ 0 ] ) . toBe ( "updated pipeline ID 5" )
104104} )
105105
106+ test ( 'update-pipeline - both tag and branch' , async ( ) => {
107+ setStore ( {
108+ 'jwt-auth' : JSON . stringify ( {
109+ client_id : '1234' ,
110+ jwt_payload : {
111+ iss : "good"
112+ }
113+ } ) ,
114+ } )
115+
116+ expect . assertions ( 2 )
117+
118+ let runResult = UpdatePipelineCommand . run ( [ "--programId" , "5" , "5" , "--branch" , "develop" , "--tag" , "foo" ] )
119+ await expect ( runResult instanceof Promise ) . toBeTruthy ( )
120+ await expect ( runResult ) . rejects . toSatisfy ( err => err . message . indexOf ( "Both branch and tag cannot be specified" ) === 0 )
121+ } )
122+
123+ test ( 'update-pipeline - malformed tag' , async ( ) => {
124+ setStore ( {
125+ 'jwt-auth' : JSON . stringify ( {
126+ client_id : '1234' ,
127+ jwt_payload : {
128+ iss : "good"
129+ }
130+ } ) ,
131+ } )
132+
133+ expect . assertions ( 2 )
134+
135+ let runResult = UpdatePipelineCommand . run ( [ "--programId" , "5" , "5" , "--tag" , "refs/tags/foo" ] )
136+ await expect ( runResult instanceof Promise ) . toBeTruthy ( )
137+ await expect ( runResult ) . rejects . toSatisfy ( err => err . message . indexOf ( "tag flag should not be specified with \"refs/tags/\" prefix. Value provided was refs/tags/foo" ) === 0 )
138+ } )
139+
140+
141+ test ( 'update-pipeline - correct tag' , async ( ) => {
142+ setStore ( {
143+ 'jwt-auth' : JSON . stringify ( {
144+ client_id : '1234' ,
145+ jwt_payload : {
146+ iss : "good"
147+ }
148+ } ) ,
149+ } )
150+
151+ expect . assertions ( 3 )
152+
153+ let runResult = UpdatePipelineCommand . run ( [ "--programId" , "5" , "5" , "--tag" , "foo" ] )
154+ await expect ( runResult instanceof Promise ) . toBeTruthy ( )
155+ await expect ( runResult ) . resolves . toMatchObject ( {
156+ phases : expect . arrayContaining ( [ {
157+ name : 'BUILD_1' ,
158+ branch : 'refs/tags/foo' ,
159+ type : 'BUILD' ,
160+ repositoryId : '1'
161+ } ] )
162+ } )
163+ await expect ( cli . action . stop . mock . calls [ 0 ] [ 0 ] ) . toBe ( "updated pipeline ID 5" )
164+ } )
106165
0 commit comments