File tree Expand file tree Collapse file tree 3 files changed +7
-10
lines changed
Expand file tree Collapse file tree 3 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -2798,9 +2798,6 @@ The config file should contain every possible key for documentation purposes."
27982798 . arg ( server. uri ( ) )
27992799 . assert ( )
28002800 . success ( ) ;
2801-
2802- // wiremock will fail if the expected request was not received
2803- server. verify ( ) . await ;
28042801 }
28052802
28062803 #[ tokio:: test]
@@ -2825,8 +2822,9 @@ The config file should contain every possible key for documentation purposes."
28252822 let user_agent = received_request
28262823 . headers
28272824 . get ( "user-agent" )
2828- . and_then ( |v| v. to_str ( ) . ok ( ) )
2829- . unwrap_or ( "" ) ;
2825+ . expect ( "User agent missing" )
2826+ . to_str ( )
2827+ . unwrap ( ) ;
28302828
28312829 assert ! (
28322830 user_agent. starts_with( "lychee/" ) ,
Original file line number Diff line number Diff line change @@ -621,13 +621,13 @@ mod tests {
621621 use wiremock:: { Mock , MockServer , ResponseTemplate } ;
622622
623623 let mock_server = MockServer :: start ( ) . await ;
624+ let uri = Uri :: try_from ( "https://example.com" ) . unwrap ( ) ;
624625
625626 Mock :: given ( method ( "GET" ) )
626627 . and ( path ( "/" ) )
627628 . and ( header ( "user-agent" , "test-agent/1.0" ) )
628629 . respond_with (
629- ResponseTemplate :: new ( 200 )
630- . set_body_string ( r#"<a href="https://example.com">Link</a>"# ) ,
630+ ResponseTemplate :: new ( 200 ) . set_body_string ( format ! ( r#"<a href="{uri}">Link</a>"# ) ) ,
631631 )
632632 . expect ( 1 )
633633 . mount ( & mock_server)
@@ -653,8 +653,7 @@ mod tests {
653653 . collect :: < std:: collections:: HashSet < _ > > ( )
654654 . await ;
655655
656- assert ! ( links. iter( ) . any( |u| u. url. as_str( ) . contains( "example.com" ) ) ) ;
657- // wiremock will panic here if the expected request was not received
656+ assert_eq ! ( links, HashSet :: from( [ uri] ) ) ;
658657 }
659658
660659 #[ tokio:: test]
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ impl UrlContentResolver {
5151 // Fetch with body since we need to extract links from the content.
5252 let response = self . host_pool . execute_request ( request, true ) . await ?;
5353
54- // needs_body=true above guarantees text is populated on success.
54+ // SAFETY: needs_body=true above guarantees text is populated on success.
5555 let content = response. text . unwrap_or_else ( || {
5656 unreachable ! ( "execute_request with needs_body=true always returns text" )
5757 } ) ;
You can’t perform that action at this time.
0 commit comments