@@ -292,6 +292,7 @@ mod tests {
292
292
use std:: future:: Future ;
293
293
294
294
use htsget_config:: storage:: local:: LocalStorage as ConfigLocalStorage ;
295
+ use htsget_test:: http:: concat:: ConcatResponse ;
295
296
use htsget_test:: util:: expected_cram_eof_data_url;
296
297
297
298
#[ cfg( feature = "s3-storage" ) ]
@@ -304,6 +305,7 @@ mod tests {
304
305
305
306
const DATA_LOCATION : & str = "data/cram" ;
306
307
const INDEX_FILE_LOCATION : & str = "htsnexus_test_NA12878.cram.crai" ;
308
+ const CRAM_FILE_NAME : & str = "htsnexus_test_NA12878.cram" ;
307
309
308
310
#[ tokio:: test]
309
311
async fn search_all_reads ( ) {
@@ -317,11 +319,13 @@ mod tests {
317
319
Format :: Cram ,
318
320
vec ! [
319
321
Url :: new( expected_url( ) )
320
- . with_headers( Headers :: default ( ) . with_header( "Range" , "bytes=0-1627755 " ) ) ,
322
+ . with_headers( Headers :: default ( ) . with_header( "Range" , "bytes=0-1672409 " ) ) ,
321
323
Url :: new( expected_cram_eof_data_url( ) ) ,
322
324
] ,
323
325
) ) ;
324
- assert_eq ! ( response, expected_response)
326
+ assert_eq ! ( response, expected_response) ;
327
+
328
+ Some ( ( CRAM_FILE_NAME . to_string ( ) , ( response. unwrap ( ) , Body ) . into ( ) ) )
325
329
} )
326
330
. await ;
327
331
}
@@ -339,21 +343,47 @@ mod tests {
339
343
Format :: Cram ,
340
344
vec ! [
341
345
Url :: new( expected_url( ) )
342
- . with_headers( Headers :: default ( ) . with_header( "Range" , "bytes=0-6086 " ) )
346
+ . with_headers( Headers :: default ( ) . with_header( "Range" , "bytes=0-6133 " ) )
343
347
. with_class( Header ) ,
344
348
Url :: new( expected_url( ) )
345
- . with_headers( Headers :: default ( ) . with_header( "Range" , "bytes=1280106-1627755 " ) )
349
+ . with_headers( Headers :: default ( ) . with_header( "Range" , "bytes=1324614-1672409 " ) )
346
350
. with_class( Body ) ,
347
351
Url :: new( expected_cram_eof_data_url( ) ) . with_class( Body ) ,
348
352
] ,
349
353
) ) ;
350
- assert_eq ! ( response, expected_response)
354
+ assert_eq ! ( response, expected_response) ;
355
+
356
+ Some ( ( CRAM_FILE_NAME . to_string ( ) , ( response. unwrap ( ) , Body ) . into ( ) ) )
351
357
} )
352
358
. await ;
353
359
}
354
360
355
361
#[ tokio:: test]
356
- async fn search_reference_name_without_seq_range ( ) {
362
+ async fn search_reference_name_without_seq_range_chr11 ( ) {
363
+ with_local_storage ( |storage| async move {
364
+ let search = CramSearch :: new ( storage. clone ( ) ) ;
365
+ let query = Query :: new_with_default_request ( "htsnexus_test_NA12878" , Format :: Cram )
366
+ . with_reference_name ( "11" ) ;
367
+ let response = search. search ( query) . await ;
368
+ println ! ( "{response:#?}" ) ;
369
+
370
+ let expected_response = Ok ( Response :: new (
371
+ Format :: Cram ,
372
+ vec ! [
373
+ Url :: new( expected_url( ) )
374
+ . with_headers( Headers :: default ( ) . with_header( "Range" , "bytes=0-625727" ) ) ,
375
+ Url :: new( expected_cram_eof_data_url( ) ) ,
376
+ ] ,
377
+ ) ) ;
378
+ assert_eq ! ( response, expected_response) ;
379
+
380
+ Some ( ( CRAM_FILE_NAME . to_string ( ) , ( response. unwrap ( ) , Body ) . into ( ) ) )
381
+ } )
382
+ . await ;
383
+ }
384
+
385
+ #[ tokio:: test]
386
+ async fn search_reference_name_without_seq_range_chr20 ( ) {
357
387
with_local_storage ( |storage| async move {
358
388
let search = CramSearch :: new ( storage. clone ( ) ) ;
359
389
let query = Query :: new_with_default_request ( "htsnexus_test_NA12878" , Format :: Cram )
@@ -365,15 +395,17 @@ mod tests {
365
395
Format :: Cram ,
366
396
vec ! [
367
397
Url :: new( expected_url( ) )
368
- . with_headers( Headers :: default ( ) . with_header( "Range" , "bytes=0-6086 " ) )
398
+ . with_headers( Headers :: default ( ) . with_header( "Range" , "bytes=0-6133 " ) )
369
399
. with_class( Header ) ,
370
400
Url :: new( expected_url( ) )
371
- . with_headers( Headers :: default ( ) . with_header( "Range" , "bytes=604231-1280105 " ) )
401
+ . with_headers( Headers :: default ( ) . with_header( "Range" , "bytes=625728-1324613 " ) )
372
402
. with_class( Body ) ,
373
403
Url :: new( expected_cram_eof_data_url( ) ) . with_class( Body ) ,
374
404
] ,
375
405
) ) ;
376
- assert_eq ! ( response, expected_response)
406
+ assert_eq ! ( response, expected_response) ;
407
+
408
+ Some ( ( CRAM_FILE_NAME . to_string ( ) , ( response. unwrap ( ) , Body ) . into ( ) ) )
377
409
} )
378
410
. await ;
379
411
}
@@ -393,11 +425,13 @@ mod tests {
393
425
Format :: Cram ,
394
426
vec ! [
395
427
Url :: new( expected_url( ) )
396
- . with_headers( Headers :: default ( ) . with_header( "Range" , "bytes=0-465708 " ) ) ,
428
+ . with_headers( Headers :: default ( ) . with_header( "Range" , "bytes=0-480537 " ) ) ,
397
429
Url :: new( expected_cram_eof_data_url( ) ) ,
398
430
] ,
399
431
) ) ;
400
- assert_eq ! ( response, expected_response)
432
+ assert_eq ! ( response, expected_response) ;
433
+
434
+ Some ( ( CRAM_FILE_NAME . to_string ( ) , ( response. unwrap ( ) , Body ) . into ( ) ) )
401
435
} )
402
436
. await ;
403
437
}
@@ -414,7 +448,9 @@ mod tests {
414
448
println ! ( "{response:#?}" ) ;
415
449
416
450
let expected_response = Ok ( expected_response_with_start ( ) ) ;
417
- assert_eq ! ( response, expected_response)
451
+ assert_eq ! ( response, expected_response) ;
452
+
453
+ Some ( ( CRAM_FILE_NAME . to_string ( ) , ( response. unwrap ( ) , Body ) . into ( ) ) )
418
454
} )
419
455
. await ;
420
456
}
@@ -430,7 +466,9 @@ mod tests {
430
466
println ! ( "{response:#?}" ) ;
431
467
432
468
let expected_response = Ok ( expected_response_with_start ( ) ) ;
433
- assert_eq ! ( response, expected_response)
469
+ assert_eq ! ( response, expected_response) ;
470
+
471
+ Some ( ( CRAM_FILE_NAME . to_string ( ) , ( response. unwrap ( ) , Body ) . into ( ) ) )
434
472
} )
435
473
. await ;
436
474
}
@@ -440,7 +478,7 @@ mod tests {
440
478
Format :: Cram ,
441
479
vec ! [
442
480
Url :: new( expected_url( ) )
443
- . with_headers( Headers :: default ( ) . with_header( "Range" , "bytes=0-604230 " ) ) ,
481
+ . with_headers( Headers :: default ( ) . with_header( "Range" , "bytes=0-625727 " ) ) ,
444
482
Url :: new( expected_cram_eof_data_url( ) ) ,
445
483
] ,
446
484
)
@@ -458,10 +496,15 @@ mod tests {
458
496
let expected_response = Ok ( Response :: new (
459
497
Format :: Cram ,
460
498
vec ! [ Url :: new( expected_url( ) )
461
- . with_headers( Headers :: default ( ) . with_header( "Range" , "bytes=0-6086 " ) )
499
+ . with_headers( Headers :: default ( ) . with_header( "Range" , "bytes=0-6133 " ) )
462
500
. with_class( Header ) ] ,
463
501
) ) ;
464
- assert_eq ! ( response, expected_response)
502
+ assert_eq ! ( response, expected_response) ;
503
+
504
+ Some ( (
505
+ CRAM_FILE_NAME . to_string ( ) ,
506
+ ( response. unwrap ( ) , Header ) . into ( ) ,
507
+ ) )
465
508
} )
466
509
. await ;
467
510
}
@@ -474,6 +517,8 @@ mod tests {
474
517
let query = Query :: new_with_default_request ( "htsnexus_test_NA12878" , Format :: Cram ) ;
475
518
let response = search. search ( query) . await ;
476
519
assert ! ( matches!( response, Err ( NotFound ( _) ) ) ) ;
520
+
521
+ None
477
522
} ,
478
523
DATA_LOCATION ,
479
524
& [ INDEX_FILE_LOCATION ] ,
@@ -490,6 +535,8 @@ mod tests {
490
535
. with_reference_name ( "20" ) ;
491
536
let response = search. search ( query) . await ;
492
537
assert ! ( matches!( response, Err ( NotFound ( _) ) ) ) ;
538
+
539
+ None
493
540
} ,
494
541
DATA_LOCATION ,
495
542
& [ INDEX_FILE_LOCATION ] ,
@@ -506,6 +553,8 @@ mod tests {
506
553
Query :: new_with_default_request ( "htsnexus_test_NA12878" , Format :: Cram ) . with_class ( Header ) ;
507
554
let response = search. search ( query) . await ;
508
555
assert ! ( matches!( response, Err ( NotFound ( _) ) ) ) ;
556
+
557
+ None
509
558
} ,
510
559
DATA_LOCATION ,
511
560
& [ INDEX_FILE_LOCATION ] ,
@@ -522,6 +571,8 @@ mod tests {
522
571
let query = Query :: new_with_default_request ( "htsnexus_test_NA12878" , Format :: Cram ) ;
523
572
let response = search. search ( query) . await ;
524
573
assert ! ( response. is_err( ) ) ;
574
+
575
+ None
525
576
} ,
526
577
DATA_LOCATION ,
527
578
& [ INDEX_FILE_LOCATION ] ,
@@ -539,6 +590,8 @@ mod tests {
539
590
. with_reference_name ( "20" ) ;
540
591
let response = search. search ( query) . await ;
541
592
assert ! ( response. is_err( ) ) ;
593
+
594
+ None
542
595
} ,
543
596
DATA_LOCATION ,
544
597
& [ INDEX_FILE_LOCATION ] ,
@@ -556,6 +609,8 @@ mod tests {
556
609
Query :: new_with_default_request ( "htsnexus_test_NA12878" , Format :: Cram ) . with_class ( Header ) ;
557
610
let response = search. search ( query) . await ;
558
611
assert ! ( response. is_err( ) ) ;
612
+
613
+ None
559
614
} ,
560
615
DATA_LOCATION ,
561
616
& [ INDEX_FILE_LOCATION ] ,
@@ -566,7 +621,7 @@ mod tests {
566
621
async fn with_local_storage < F , Fut > ( test : F )
567
622
where
568
623
F : FnOnce ( Arc < LocalStorage < ConfigLocalStorage > > ) -> Fut ,
569
- Fut : Future < Output = ( ) > ,
624
+ Fut : Future < Output = Option < ( String , ConcatResponse ) > > ,
570
625
{
571
626
with_local_storage_fn ( test, "data/cram" , & [ ] ) . await
572
627
}
0 commit comments