1- use crate :: parse:: { assert_url, url} ;
1+ use crate :: parse:: { assert_url, assert_url_and , url} ;
22use git_url:: owned:: UserExpansion ;
33use git_url:: Protocol ;
4+ use std:: path:: Path ;
45
56#[ test]
67fn without_user_and_without_port ( ) -> crate :: Result {
@@ -25,7 +26,7 @@ fn host_is_ipv4() -> crate::Result {
2526
2627#[ test]
2728fn username_expansion_with_username ( ) -> crate :: Result {
28- assert_url (
29+ let expanded_path = assert_url_and (
2930 "ssh://example.com/~byron/hello" ,
3031 url (
3132 Protocol :: Ssh ,
@@ -35,12 +36,18 @@ fn username_expansion_with_username() -> crate::Result {
3536 b"/hello" ,
3637 UserExpansion :: Name ( "byron" . into ( ) ) ,
3738 ) ,
38- )
39+ ) ?
40+ . expand_path_with ( |user : & UserExpansion | match user {
41+ UserExpansion :: Current => unreachable ! ( "we have a name" ) ,
42+ UserExpansion :: Name ( name) => Some ( format ! ( "/home/{}" , name) . into ( ) ) ,
43+ } ) ;
44+ assert_eq ! ( expanded_path, Some ( Path :: new( "/home/byron/hello" ) . into( ) ) ) ;
45+ Ok ( ( ) )
3946}
4047
4148#[ test]
4249fn username_expansion_without_username ( ) -> crate :: Result {
43- assert_url (
50+ let expanded_path = assert_url_and (
4451 "ssh://example.com/~/hello/git" ,
4552 url (
4653 Protocol :: Ssh ,
@@ -50,7 +57,13 @@ fn username_expansion_without_username() -> crate::Result {
5057 b"/hello/git" ,
5158 UserExpansion :: Current ,
5259 ) ,
53- )
60+ ) ?
61+ . expand_path_with ( |user : & UserExpansion | match user {
62+ UserExpansion :: Current => Some ( "/home/byron" . into ( ) ) ,
63+ UserExpansion :: Name ( name) => Some ( format ! ( "/home/{}" , name) . into ( ) ) ,
64+ } ) ;
65+ assert_eq ! ( expanded_path, Some ( Path :: new( "/home/byron/hello/git" ) . into( ) ) ) ;
66+ Ok ( ( ) )
5467}
5568
5669#[ test]
0 commit comments