@@ -294,58 +294,6 @@ impl TryFrom<Vec<u8>> for JsonResponse {
294294 }
295295}
296296
297- #[ cfg( test) ]
298- mod endpoint_tests {
299- use super :: HttpEndpoint ;
300-
301- #[ test]
302- fn with_default_port ( ) {
303- let endpoint = HttpEndpoint :: for_host ( "foo.com" . into ( ) ) ;
304- assert_eq ! ( endpoint. host( ) , "foo.com" ) ;
305- assert_eq ! ( endpoint. port( ) , 80 ) ;
306- }
307-
308- #[ test]
309- fn with_custom_port ( ) {
310- let endpoint = HttpEndpoint :: for_host ( "foo.com" . into ( ) ) . with_port ( 8080 ) ;
311- assert_eq ! ( endpoint. host( ) , "foo.com" ) ;
312- assert_eq ! ( endpoint. port( ) , 8080 ) ;
313- }
314-
315- #[ test]
316- fn with_uri_path ( ) {
317- let endpoint = HttpEndpoint :: for_host ( "foo.com" . into ( ) ) . with_path ( "/path" . into ( ) ) ;
318- assert_eq ! ( endpoint. host( ) , "foo.com" ) ;
319- assert_eq ! ( endpoint. path( ) , "/path" ) ;
320- }
321-
322- #[ test]
323- fn without_uri_path ( ) {
324- let endpoint = HttpEndpoint :: for_host ( "foo.com" . into ( ) ) ;
325- assert_eq ! ( endpoint. host( ) , "foo.com" ) ;
326- assert_eq ! ( endpoint. path( ) , "/" ) ;
327- }
328-
329- #[ test]
330- fn convert_to_socket_addrs ( ) {
331- let endpoint = HttpEndpoint :: for_host ( "localhost" . into ( ) ) ;
332- let host = endpoint. host ( ) ;
333- let port = endpoint. port ( ) ;
334-
335- use std:: net:: ToSocketAddrs ;
336- match ( & endpoint) . to_socket_addrs ( ) {
337- Err ( e) => panic ! ( "Unexpected error: {:?}" , e) ,
338- Ok ( socket_addrs) => {
339- let mut std_addrs = ( host, port) . to_socket_addrs ( ) . unwrap ( ) ;
340- for addr in socket_addrs {
341- assert_eq ! ( addr, std_addrs. next( ) . unwrap( ) ) ;
342- }
343- assert ! ( std_addrs. next( ) . is_none( ) ) ;
344- } ,
345- }
346- }
347- }
348-
349297#[ cfg( test) ]
350298pub ( crate ) mod client_tests {
351299 use super :: * ;
@@ -498,21 +446,6 @@ pub(crate) mod client_tests {
498446 }
499447 }
500448
501- #[ test]
502- fn connect_to_unresolvable_host ( ) {
503- match HttpClient :: connect ( ( "example.invalid" , 80 ) ) {
504- Err ( e) => {
505- assert ! (
506- e. to_string( ) . contains( "failed to lookup address information" )
507- || e. to_string( ) . contains( "No such host" ) ,
508- "{:?}" ,
509- e
510- ) ;
511- } ,
512- Ok ( _) => panic ! ( "Expected error" ) ,
513- }
514- }
515-
516449 #[ test]
517450 fn connect_with_no_socket_address ( ) {
518451 match HttpClient :: connect ( & vec ! [ ] [ ..] ) {
@@ -524,24 +457,6 @@ pub(crate) mod client_tests {
524457 }
525458 }
526459
527- #[ tokio:: test]
528- async fn request_to_unreachable_server ( ) {
529- // Get an unused port by binding to port 0
530- let port = {
531- let t = std:: net:: TcpListener :: bind ( ( "127.0.0.1" , 0 ) ) . unwrap ( ) ;
532- t. local_addr ( ) . unwrap ( ) . port ( )
533- } ;
534-
535- // Connect succeeds (just resolves address), but request fails
536- let endpoint = HttpEndpoint :: for_host ( "127.0.0.1" . to_string ( ) ) . with_port ( port) ;
537- let mut client = HttpClient :: connect ( & endpoint) . unwrap ( ) ;
538- match client. get :: < BinaryResponse > ( "/" ) . await {
539- Err ( HttpClientError :: Transport ( _) ) => { } ,
540- Err ( e) => panic ! ( "Unexpected error type: {:?}" , e) ,
541- Ok ( _) => panic ! ( "Expected error" ) ,
542- }
543- }
544-
545460 #[ tokio:: test]
546461 async fn read_error ( ) {
547462 let server = HttpServer :: responding_with_server_error ( "foo" ) ;
0 commit comments