@@ -73,38 +73,28 @@ mod destructure_url_in_place {
7373        ) ; 
7474    } 
7575
76-     #[ test]  
77-     fn  protocol_and_host_without_url_constructs_url_first ( )  { 
78-         let  mut  ctx = Context  { 
79-             protocol :  Some ( "https" . into ( ) ) , 
80-             host :  Some ( "github.com" . into ( ) ) , 
81-             ..Default :: default ( ) 
82-         } ; 
83-         ctx. destructure_url_in_place ( false ) . expect ( "should work with protocol and host" ) ; 
84-         
85-         // URL should be constructed from protocol and host 
86-         assert_eq ! ( ctx. url. as_deref( ) . map( |b| & * * b) ,  Some ( "https://github.com" . as_bytes( ) ) ) ; 
87-         // Original fields should be preserved  
88-         assert_eq ! ( ctx. protocol. as_deref( ) ,  Some ( "https" ) ) ; 
89-         assert_eq ! ( ctx. host. as_deref( ) ,  Some ( "github.com" ) ) ; 
90-     } 
91- 
9276    #[ test]  
9377    fn  protocol_and_host_with_path_without_url_constructs_full_url ( )  { 
9478        let  mut  ctx = Context  { 
9579            protocol :  Some ( "https" . into ( ) ) , 
9680            host :  Some ( "github.com" . into ( ) ) , 
9781            path :  Some ( "org/repo" . into ( ) ) , 
82+             username :  Some ( "user" . into ( ) ) , 
83+             password :  Some ( "pass-to-be-ignored" . into ( ) ) , 
9884            ..Default :: default ( ) 
9985        } ; 
100-         ctx. destructure_url_in_place ( false ) . expect ( "should work with protocol, host and path" ) ; 
101-         
102-         // URL should be constructed from all provided fields 
103-         assert_eq ! ( ctx. url. as_deref( ) . map( |b| & * * b) ,  Some ( "https://github.com/org/repo" . as_bytes( ) ) ) ; 
86+         ctx. destructure_url_in_place ( false ) 
87+             . expect ( "should work with protocol, host and path" ) ; 
88+ 
89+         assert_eq ! ( 
90+             ctx. url. unwrap( ) , 
91+             "https://[email protected] /org/repo" ,  92+             "URL should be constructed from all provided fields, except password" 
93+         ) ; 
10494        // Original fields should be preserved 
10595        assert_eq ! ( ctx. protocol. as_deref( ) ,  Some ( "https" ) ) ; 
10696        assert_eq ! ( ctx. host. as_deref( ) ,  Some ( "github.com" ) ) ; 
107-         assert_eq ! ( ctx. path. as_deref ( ) . map ( |b|  & * * b ) ,   Some ( "org/repo" . as_bytes ( ) ) ) ; 
97+         assert_eq ! ( ctx. path. unwrap ( ) ,   "org/repo" ) ; 
10898    } 
10999
110100    #[ test]  
@@ -113,7 +103,10 @@ mod destructure_url_in_place {
113103            host :  Some ( "github.com" . into ( ) ) , 
114104            ..Default :: default ( ) 
115105        } ; 
116-         assert ! ( ctx_no_protocol. destructure_url_in_place( false ) . is_err( ) ) ; 
106+         assert_eq ! ( 
107+             ctx_no_protocol. destructure_url_in_place( false ) . unwrap_err( ) . to_string( ) , 
108+             "Either 'url' field or both 'protocol' and 'host' fields must be provided" 
109+         ) ; 
117110
118111        let  mut  ctx_no_host = Context  { 
119112            protocol :  Some ( "https" . into ( ) ) , 
0 commit comments