File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
crates/web-plugins/didcomm-messaging/shared/src/breaker Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -61,19 +61,25 @@ async fn test_retry_configuration() {
6161 let breaker = CircuitBreaker :: new ( ) . retries ( 2 ) ;
6262
6363 let attempts = Arc :: new ( AtomicUsize :: new ( 0 ) ) ;
64- let attempts = attempts. clone ( ) ;
65-
66- let retry_operation = || async {
67- attempts. fetch_add ( 1 , Ordering :: AcqRel ) ;
68- async { Err :: < ( ) , ( ) > ( ( ) ) } . await
64+ let attempts_clone = attempts. clone ( ) ;
65+
66+ let retry_operation = || {
67+ let attempts = attempts_clone. clone ( ) ;
68+ async move {
69+ attempts. fetch_add ( 1 , Ordering :: AcqRel ) ;
70+ Err :: < ( ) , ( ) > ( ( ) ) // Simulate a failure
71+ }
6972 } ;
7073
7174 let result = breaker. call ( retry_operation) . await ;
75+
76+ // Verify the result matches the expected error type
7277 assert ! ( matches!( result, Err ( Error :: Inner ( _) ) ) ) ;
73- // the total number of attempts should be 2
78+ // Verify that the total number of attempts was 2
7479 assert_eq ! ( attempts. load( Ordering :: Relaxed ) , 2 ) ;
7580}
7681
82+
7783#[ tokio:: test]
7884async fn test_timeout_reset ( ) {
7985 let breaker = CircuitBreaker :: new ( ) . reset_timeout ( Duration :: from_millis ( 100 ) ) ;
You can’t perform that action at this time.
0 commit comments