@@ -359,11 +359,13 @@ mod tests {
359359
360360 impl ReadStats for MockReadStats {
361361 fn count_kv_read ( & self , value : i32 ) {
362- self . kv_reads . fetch_add ( value, std:: sync:: atomic:: Ordering :: Relaxed ) ;
362+ self . kv_reads
363+ . fetch_add ( value, std:: sync:: atomic:: Ordering :: Relaxed ) ;
363364 }
364365
365366 fn count_kv_byod_read ( & self , value : i32 ) {
366- self . byod_reads . fetch_add ( value, std:: sync:: atomic:: Ordering :: Relaxed ) ;
367+ self . byod_reads
368+ . fetch_add ( value, std:: sync:: atomic:: Ordering :: Relaxed ) ;
367369 }
368370 }
369371
@@ -392,10 +394,7 @@ mod tests {
392394 param : & str ,
393395 _metric : Arc < dyn ReadStats > ,
394396 ) -> Result < Arc < dyn Store > , Error > {
395- self . stores
396- . get ( param)
397- . cloned ( )
398- . ok_or ( Error :: NoSuchStore )
397+ self . stores . get ( param) . cloned ( ) . ok_or ( Error :: NoSuchStore )
399398 }
400399 }
401400
@@ -407,9 +406,10 @@ mod tests {
407406
408407 #[ tokio:: test]
409408 async fn test_builder_new ( ) {
410- let allowed_stores = vec ! [
411- ( SmolStr :: new( "store1" ) , SmolStr :: new( "redis://localhost:6379" ) ) ,
412- ] ;
409+ let allowed_stores = vec ! [ (
410+ SmolStr :: new( "store1" ) ,
411+ SmolStr :: new( "redis://localhost:6379" ) ,
412+ ) ] ;
413413 let manager = Arc :: new ( NoSuchStoreManager ) ;
414414 let builder = Builder :: new ( allowed_stores. clone ( ) , manager) ;
415415
@@ -421,13 +421,13 @@ mod tests {
421421 async fn test_store_impl_open_allowed_store ( ) {
422422 let mock_store = Arc :: new ( MockStore :: new ( ) ) ;
423423 let manager = Arc :: new (
424- MockStoreManager :: new ( )
425- . with_store ( "redis://localhost:6379" , mock_store. clone ( ) )
424+ MockStoreManager :: new ( ) . with_store ( "redis://localhost:6379" , mock_store. clone ( ) ) ,
426425 ) ;
427426
428- let allowed_stores = vec ! [
429- ( SmolStr :: new( "mystore" ) , SmolStr :: new( "redis://localhost:6379" ) ) ,
430- ] ;
427+ let allowed_stores = vec ! [ (
428+ SmolStr :: new( "mystore" ) ,
429+ SmolStr :: new( "redis://localhost:6379" ) ,
430+ ) ] ;
431431 let stats = Arc :: new ( MockReadStats :: new ( ) ) ;
432432 let mut store_impl = Builder :: new ( allowed_stores, manager) . build ( stats. clone ( ) ) ;
433433
@@ -439,9 +439,10 @@ mod tests {
439439 #[ tokio:: test]
440440 async fn test_store_impl_open_denied_store ( ) {
441441 let manager = Arc :: new ( NoSuchStoreManager ) ;
442- let allowed_stores = vec ! [
443- ( SmolStr :: new( "allowed" ) , SmolStr :: new( "redis://localhost:6379" ) ) ,
444- ] ;
442+ let allowed_stores = vec ! [ (
443+ SmolStr :: new( "allowed" ) ,
444+ SmolStr :: new( "redis://localhost:6379" ) ,
445+ ) ] ;
445446 let stats = Arc :: new ( MockReadStats :: new ( ) ) ;
446447 let mut store_impl = Builder :: new ( allowed_stores, manager) . build ( stats. clone ( ) ) ;
447448
@@ -456,7 +457,7 @@ mod tests {
456457 let manager = Arc :: new (
457458 MockStoreManager :: new ( )
458459 . with_store ( "redis://store1" , mock_store1. clone ( ) )
459- . with_store ( "redis://store2" , mock_store2. clone ( ) )
460+ . with_store ( "redis://store2" , mock_store2. clone ( ) ) ,
460461 ) ;
461462
462463 let allowed_stores = vec ! [
@@ -475,16 +476,10 @@ mod tests {
475476
476477 #[ tokio:: test]
477478 async fn test_get_value_success ( ) {
478- let mock_store = Arc :: new (
479- MockStore :: new ( ) . with_data ( "key1" , b"value1" . to_vec ( ) )
480- ) ;
481- let manager = Arc :: new (
482- MockStoreManager :: new ( ) . with_store ( "redis://localhost" , mock_store)
483- ) ;
479+ let mock_store = Arc :: new ( MockStore :: new ( ) . with_data ( "key1" , b"value1" . to_vec ( ) ) ) ;
480+ let manager = Arc :: new ( MockStoreManager :: new ( ) . with_store ( "redis://localhost" , mock_store) ) ;
484481
485- let allowed_stores = vec ! [
486- ( SmolStr :: new( "mystore" ) , SmolStr :: new( "redis://localhost" ) ) ,
487- ] ;
482+ let allowed_stores = vec ! [ ( SmolStr :: new( "mystore" ) , SmolStr :: new( "redis://localhost" ) ) ] ;
488483 let stats = Arc :: new ( MockReadStats :: new ( ) ) ;
489484 let mut store_impl = Builder :: new ( allowed_stores, manager) . build ( stats. clone ( ) ) ;
490485
@@ -498,13 +493,9 @@ mod tests {
498493 #[ tokio:: test]
499494 async fn test_get_value_not_found ( ) {
500495 let mock_store = Arc :: new ( MockStore :: new ( ) ) ;
501- let manager = Arc :: new (
502- MockStoreManager :: new ( ) . with_store ( "redis://localhost" , mock_store)
503- ) ;
496+ let manager = Arc :: new ( MockStoreManager :: new ( ) . with_store ( "redis://localhost" , mock_store) ) ;
504497
505- let allowed_stores = vec ! [
506- ( SmolStr :: new( "mystore" ) , SmolStr :: new( "redis://localhost" ) ) ,
507- ] ;
498+ let allowed_stores = vec ! [ ( SmolStr :: new( "mystore" ) , SmolStr :: new( "redis://localhost" ) ) ] ;
508499 let stats = Arc :: new ( MockReadStats :: new ( ) ) ;
509500 let mut store_impl = Builder :: new ( allowed_stores, manager) . build ( stats. clone ( ) ) ;
510501
@@ -534,18 +525,16 @@ mod tests {
534525 ( b"item4" . to_vec( ) , 7.5 ) ,
535526 ] ;
536527 let mock_store = Arc :: new ( MockStore :: new ( ) . with_zset ( "sorted_set" , items) ) ;
537- let manager = Arc :: new (
538- MockStoreManager :: new ( ) . with_store ( "redis://localhost" , mock_store)
539- ) ;
528+ let manager = Arc :: new ( MockStoreManager :: new ( ) . with_store ( "redis://localhost" , mock_store) ) ;
540529
541- let allowed_stores = vec ! [
542- ( SmolStr :: new( "mystore" ) , SmolStr :: new( "redis://localhost" ) ) ,
543- ] ;
530+ let allowed_stores = vec ! [ ( SmolStr :: new( "mystore" ) , SmolStr :: new( "redis://localhost" ) ) ] ;
544531 let stats = Arc :: new ( MockReadStats :: new ( ) ) ;
545532 let mut store_impl = Builder :: new ( allowed_stores, manager) . build ( stats. clone ( ) ) ;
546533
547534 let store_id = store_impl. open ( "mystore" ) . await . unwrap ( ) ;
548- let result = store_impl. zrange_by_score ( store_id, "sorted_set" , 2.0 , 6.0 ) . await ;
535+ let result = store_impl
536+ . zrange_by_score ( store_id, "sorted_set" , 2.0 , 6.0 )
537+ . await ;
549538
550539 assert ! ( result. is_ok( ) ) ;
551540 let items = result. unwrap ( ) ;
@@ -570,15 +559,11 @@ mod tests {
570559 MockStore :: new ( )
571560 . with_data ( "user:1" , b"alice" . to_vec ( ) )
572561 . with_data ( "user:2" , b"bob" . to_vec ( ) )
573- . with_data ( "post:1" , b"hello" . to_vec ( ) )
574- ) ;
575- let manager = Arc :: new (
576- MockStoreManager :: new ( ) . with_store ( "redis://localhost" , mock_store)
562+ . with_data ( "post:1" , b"hello" . to_vec ( ) ) ,
577563 ) ;
564+ let manager = Arc :: new ( MockStoreManager :: new ( ) . with_store ( "redis://localhost" , mock_store) ) ;
578565
579- let allowed_stores = vec ! [
580- ( SmolStr :: new( "mystore" ) , SmolStr :: new( "redis://localhost" ) ) ,
581- ] ;
566+ let allowed_stores = vec ! [ ( SmolStr :: new( "mystore" ) , SmolStr :: new( "redis://localhost" ) ) ] ;
582567 let stats = Arc :: new ( MockReadStats :: new ( ) ) ;
583568 let mut store_impl = Builder :: new ( allowed_stores, manager) . build ( stats. clone ( ) ) ;
584569
@@ -610,13 +595,9 @@ mod tests {
610595 ( b"banana" . to_vec( ) , 3.0 ) ,
611596 ] ;
612597 let mock_store = Arc :: new ( MockStore :: new ( ) . with_zset ( "fruits" , items) ) ;
613- let manager = Arc :: new (
614- MockStoreManager :: new ( ) . with_store ( "redis://localhost" , mock_store)
615- ) ;
598+ let manager = Arc :: new ( MockStoreManager :: new ( ) . with_store ( "redis://localhost" , mock_store) ) ;
616599
617- let allowed_stores = vec ! [
618- ( SmolStr :: new( "mystore" ) , SmolStr :: new( "redis://localhost" ) ) ,
619- ] ;
600+ let allowed_stores = vec ! [ ( SmolStr :: new( "mystore" ) , SmolStr :: new( "redis://localhost" ) ) ] ;
620601 let stats = Arc :: new ( MockReadStats :: new ( ) ) ;
621602 let mut store_impl = Builder :: new ( allowed_stores, manager) . build ( stats. clone ( ) ) ;
622603
@@ -641,18 +622,12 @@ mod tests {
641622 #[ tokio:: test]
642623 async fn test_bf_exists_true ( ) {
643624 let mock_store = Arc :: new (
644- MockStore :: new ( ) . with_bloom (
645- "bloom_key" ,
646- vec ! [ "item1" . to_string( ) , "item2" . to_string( ) ] ,
647- )
648- ) ;
649- let manager = Arc :: new (
650- MockStoreManager :: new ( ) . with_store ( "redis://localhost" , mock_store)
625+ MockStore :: new ( )
626+ . with_bloom ( "bloom_key" , vec ! [ "item1" . to_string( ) , "item2" . to_string( ) ] ) ,
651627 ) ;
628+ let manager = Arc :: new ( MockStoreManager :: new ( ) . with_store ( "redis://localhost" , mock_store) ) ;
652629
653- let allowed_stores = vec ! [
654- ( SmolStr :: new( "mystore" ) , SmolStr :: new( "redis://localhost" ) ) ,
655- ] ;
630+ let allowed_stores = vec ! [ ( SmolStr :: new( "mystore" ) , SmolStr :: new( "redis://localhost" ) ) ] ;
656631 let stats = Arc :: new ( MockReadStats :: new ( ) ) ;
657632 let mut store_impl = Builder :: new ( allowed_stores, manager) . build ( stats. clone ( ) ) ;
658633
@@ -665,21 +640,18 @@ mod tests {
665640
666641 #[ tokio:: test]
667642 async fn test_bf_exists_false ( ) {
668- let mock_store = Arc :: new (
669- MockStore :: new ( ) . with_bloom ( "bloom_key" , vec ! [ "item1" . to_string( ) ] )
670- ) ;
671- let manager = Arc :: new (
672- MockStoreManager :: new ( ) . with_store ( "redis://localhost" , mock_store)
673- ) ;
643+ let mock_store =
644+ Arc :: new ( MockStore :: new ( ) . with_bloom ( "bloom_key" , vec ! [ "item1" . to_string( ) ] ) ) ;
645+ let manager = Arc :: new ( MockStoreManager :: new ( ) . with_store ( "redis://localhost" , mock_store) ) ;
674646
675- let allowed_stores = vec ! [
676- ( SmolStr :: new( "mystore" ) , SmolStr :: new( "redis://localhost" ) ) ,
677- ] ;
647+ let allowed_stores = vec ! [ ( SmolStr :: new( "mystore" ) , SmolStr :: new( "redis://localhost" ) ) ] ;
678648 let stats = Arc :: new ( MockReadStats :: new ( ) ) ;
679649 let mut store_impl = Builder :: new ( allowed_stores, manager) . build ( stats. clone ( ) ) ;
680650
681651 let store_id = store_impl. open ( "mystore" ) . await . unwrap ( ) ;
682- let result = store_impl. bf_exists ( store_id, "bloom_key" , "nonexistent" ) . await ;
652+ let result = store_impl
653+ . bf_exists ( store_id, "bloom_key" , "nonexistent" )
654+ . await ;
683655
684656 assert ! ( result. is_ok( ) ) ;
685657 assert_eq ! ( result. unwrap( ) , false ) ;
0 commit comments