@@ -557,6 +557,127 @@ def update_app
557557 end
558558 end
559559
560+ describe 'read app' do
561+ let ( :process ) { ProcessModelFactory . make ( instances : 1 ) }
562+ let ( :app_model ) { process . app }
563+ let ( :developer ) { make_developer_for_space ( process . space ) }
564+ let ( :app_guid ) { process . app_guid }
565+
566+ before do
567+ set_current_user ( developer )
568+ allow_any_instance_of ( V2 ::AppStage ) . to receive ( :stage ) . and_return ( nil )
569+ end
570+
571+ it 'returns the app in question' do
572+ get "/v2/apps/#{ app_guid } "
573+ expect ( decoded_response [ 'metadata' ] ) . to include ( {
574+ 'guid' => app_guid . to_s ,
575+ 'url' => "/v2/apps/#{ app_guid } " ,
576+ 'created_at' => anything ,
577+ 'updated_at' => anything
578+ } )
579+ expect ( decoded_response [ 'entity' ] ) . to include ( {
580+ 'name' => 'name-1' ,
581+ 'production' => false ,
582+ 'space_guid' => process . space . guid . to_s ,
583+ 'stack_guid' => process . stack . guid . to_s ,
584+ 'buildpack' => nil ,
585+ 'detected_buildpack' => nil ,
586+ 'detected_buildpack_guid' => nil ,
587+ 'environment_json' => nil ,
588+ 'memory' => 1024 ,
589+ 'instances' => 1 ,
590+ 'disk_quota' => 1024 ,
591+ 'state' => 'STOPPED' ,
592+ 'version' => anything ,
593+ 'command' => nil ,
594+ 'console' => false ,
595+ 'debug' => nil ,
596+ 'staging_task_id' => anything ,
597+ 'package_state' => 'STAGED' ,
598+ 'health_check_type' => 'port' ,
599+ 'health_check_timeout' => nil ,
600+ 'health_check_http_endpoint' => nil ,
601+ 'staging_failed_reason' => nil ,
602+ 'staging_failed_description' => nil ,
603+ 'diego' => true ,
604+ 'docker_image' => nil ,
605+ 'docker_credentials' => {
606+ 'username' => nil ,
607+ 'password' => nil
608+ } ,
609+ 'package_updated_at' => anything ,
610+ 'detected_start_command' => '$HOME/boot.sh' ,
611+ 'enable_ssh' => true ,
612+ 'ports' => [ 8080 ] ,
613+ 'space_url' => "/v2/spaces/#{ process . space . guid } " ,
614+ 'stack_url' => "/v2/stacks/#{ process . stack . guid } " ,
615+ 'routes_url' => "/v2/apps/#{ app_guid } /routes" ,
616+ 'events_url' => "/v2/apps/#{ app_guid } /events" ,
617+ 'service_bindings_url' => "/v2/apps/#{ app_guid } /service_bindings" ,
618+ 'route_mappings_url' => "/v2/apps/#{ app_guid } /route_mappings"
619+ } )
620+ end
621+
622+ context 'when the app has rolled to a new web process' do
623+ before do
624+ process . destroy
625+ ProcessModelFactory . make ( instances : 1 , app : app_model )
626+ end
627+
628+ it 'returns the app with the appropriate app guid' do
629+ get "/v2/apps/#{ app_guid } "
630+ expect ( decoded_response [ 'metadata' ] ) . to include ( {
631+ 'guid' => app_guid . to_s ,
632+ 'url' => "/v2/apps/#{ app_guid } " ,
633+ 'created_at' => anything ,
634+ 'updated_at' => anything
635+ } )
636+ expect ( decoded_response [ 'entity' ] ) . to include ( {
637+ 'name' => 'name-1' ,
638+ 'production' => false ,
639+ 'space_guid' => process . space . guid . to_s ,
640+ 'stack_guid' => process . stack . guid . to_s ,
641+ 'buildpack' => nil ,
642+ 'detected_buildpack' => nil ,
643+ 'detected_buildpack_guid' => nil ,
644+ 'environment_json' => nil ,
645+ 'memory' => 1024 ,
646+ 'instances' => 1 ,
647+ 'disk_quota' => 1024 ,
648+ 'state' => 'STOPPED' ,
649+ 'version' => anything ,
650+ 'command' => nil ,
651+ 'console' => false ,
652+ 'debug' => nil ,
653+ 'staging_task_id' => anything ,
654+ 'package_state' => 'STAGED' ,
655+ 'health_check_type' => 'port' ,
656+ 'health_check_timeout' => nil ,
657+ 'health_check_http_endpoint' => nil ,
658+ 'staging_failed_reason' => nil ,
659+ 'staging_failed_description' => nil ,
660+ 'diego' => true ,
661+ 'docker_image' => nil ,
662+ 'docker_credentials' => {
663+ 'username' => nil ,
664+ 'password' => nil
665+ } ,
666+ 'package_updated_at' => anything ,
667+ 'detected_start_command' => '$HOME/boot.sh' ,
668+ 'enable_ssh' => true ,
669+ 'ports' => [ 8080 ] ,
670+ 'space_url' => "/v2/spaces/#{ process . space . guid } " ,
671+ 'stack_url' => "/v2/stacks/#{ process . stack . guid } " ,
672+ 'routes_url' => "/v2/apps/#{ app_guid } /routes" ,
673+ 'events_url' => "/v2/apps/#{ app_guid } /events" ,
674+ 'service_bindings_url' => "/v2/apps/#{ app_guid } /service_bindings" ,
675+ 'route_mappings_url' => "/v2/apps/#{ app_guid } /route_mappings"
676+ } )
677+ end
678+ end
679+ end
680+
560681 describe 'update app' do
561682 let ( :update_hash ) { { } }
562683
0 commit comments