@@ -162,7 +162,53 @@ describe("app:install", () => {
162162 } )
163163 . it ( "should install a stack app" )
164164 } )
165+ describe ( "App is already installed" , ( ) => {
166+ test
167+ . stdout ( { print : process . env . PRINT === "true" || false } )
168+ . stub ( ux . action , "stop" , ( ) => { } )
169+ . stub ( ux . action , "start" , ( ) => { } )
170+ . stub ( cliux , "inquire" , async ( ...args : any ) => {
171+ const [ prompt ] : any = args ;
172+ const cases = {
173+ App : mock . apps [ 1 ] . name ,
174+ Organization : mock . organizations [ 0 ] . name ,
175+ } ;
176+
177+ return ( cases as Record < string , any > ) [ prompt . name ] ;
178+ } )
179+ . nock ( region . cma , ( api ) =>
180+ api
181+ . get ( "/v3/organizations?limit=100&asc=name&include_count=true&skip=0" )
182+ . reply ( 200 , { organizations : mock . organizations } )
183+ )
184+ . nock ( `https://${ developerHubBaseUrl } ` , ( api ) =>
185+ api
186+ . get ( "/manifests?limit=50&asc=name&include_count=true&skip=0" )
187+ . reply ( 200 , {
188+ data : mock . apps ,
189+ } )
190+ )
191+ . nock ( `https://${ developerHubBaseUrl } ` , ( api ) =>
192+ api
193+ . post ( `/manifests/${ mock . apps [ 1 ] . uid } /install` , {
194+ "target_type" : mock . apps [ 1 ] . target_type ,
195+ "target_uid" : mock . organizations [ 0 ] . uid
196+ } )
197+ . replyWithError ( {
198+ "status" : 400 ,
199+ "message" : "Installation for app is already done" ,
200+ "error" : "Internal Server Error"
201+ } )
202+ )
203+ . command ( [
204+ "app:install"
205+ ] )
206+ . exit ( 1 )
207+ . do ( ( { stdout} ) => {
208+ expect ( stdout ) . to . contain ( "Installation for app is already done" )
209+ } )
210+ . it ( "should fail with an error that app is already installed" )
211+ } )
165212 // describe("Invalid app provided")
166- // describe("App is already installed")
167213 // describe("Stack API Key is provided, but the app selected is an organization app")
168214} )
0 commit comments