@@ -628,6 +628,58 @@ class IngestJobTest < ActiveSupport::TestCase
628628 end
629629 end
630630
631+ test 'should handle not finding upstream jobs in ingestSummary' do
632+ study = FactoryBot . create ( :detached_study ,
633+ name_prefix : 'Empty Jobs test' ,
634+ user : @user ,
635+ test_array : @@studies_to_clean )
636+ ann_data_file = FactoryBot . create ( :ann_data_file , name : 'failed.h5ad' , study :)
637+ pipeline_name = SecureRandom . uuid
638+ dummy_job = Google ::Apis ::BatchV1 ::Job . new (
639+ name : pipeline_name ,
640+ create_time : ( @now - 1 . hour ) . to_s ,
641+ update_time : @now . to_s ,
642+ status : Google ::Apis ::BatchV1 ::JobStatus . new (
643+ state : 'FAILED' ,
644+ status_events : [
645+ Google ::Apis ::BatchV1 ::StatusEvent . new ( event_time : ( @now - 1 . hour ) . to_s ) ,
646+ Google ::Apis ::BatchV1 ::StatusEvent . new ( event_time : @now . to_s )
647+ ]
648+ )
649+ )
650+ list_mock = Minitest ::Mock . new
651+ list_mock . expect :jobs , [ ]
652+ mock = Minitest ::Mock . new
653+ mock . expect :list_jobs , list_mock
654+ mock . expect :exit_code_from_task , 1 , [ pipeline_name ]
655+ params_object = AnnDataIngestParameters . new (
656+ anndata_file : "gs://#{ study . bucket_id } /matrix.h5ad" , file_size : ann_data_file . upload_file_size
657+ )
658+ job = IngestJob . new (
659+ pipeline_name :, study :, study_file : ann_data_file , user : @user , action : :ingest_anndata , params_object :
660+ )
661+ expected_props = {
662+ perfTime : 3_600_000 ,
663+ fileName : ann_data_file . name ,
664+ fileType : ann_data_file . file_type ,
665+ fileSize : ann_data_file . upload_file_size ,
666+ studyAccession : study . accession ,
667+ trigger : ann_data_file . upload_trigger ,
668+ jobStatus : 'failed' ,
669+ numFilesExtracted : 0 ,
670+ machineType : params_object . machine_type ,
671+ action : 'unknown' ,
672+ exitCode : 1
673+ } . with_indifferent_access
674+ job . stub :get_ingest_run , dummy_job do
675+ ApplicationController . stub :batch_api_client , mock do
676+ props = job . anndata_summary_props
677+ assert_equal expected_props , props . with_indifferent_access
678+ mock . verify
679+ end
680+ end
681+ end
682+
631683 test 'should limit size when reading error logfile for email' do
632684 job = IngestJob . new ( study : @basic_study , study_file : @basic_study_exp_file , user : @user , action : :ingest_expression )
633685 file_location = @basic_study_exp_file . bucket_location
0 commit comments