@@ -619,3 +619,39 @@ fn test_url_from_file_path() {
619
619
let path = u. to_file_path ( ) . unwrap ( ) ;
620
620
assert_eq ! ( "/c:/" , path. to_str( ) . unwrap( ) ) ;
621
621
}
622
+
623
+ #[ test]
624
+ fn test_non_special_path ( ) {
625
+ let mut db_url = url:: Url :: parse ( "postgres://postgres@localhost/" ) . unwrap ( ) ;
626
+ assert_eq ! ( db_url. as_str( ) , "postgres://postgres@localhost/" ) ;
627
+ db_url. set_path ( "diesel_foo" ) ;
628
+ assert_eq ! ( db_url. as_str( ) , "postgres://postgres@localhost/diesel_foo" ) ;
629
+ assert_eq ! ( db_url. path( ) , "/diesel_foo" ) ;
630
+ }
631
+
632
+ #[ test]
633
+ fn test_non_special_path2 ( ) {
634
+ let mut db_url = url:: Url :: parse ( "postgres://postgres@localhost/" ) . unwrap ( ) ;
635
+ assert_eq ! ( db_url. as_str( ) , "postgres://postgres@localhost/" ) ;
636
+ db_url. set_path ( "" ) ;
637
+ assert_eq ! ( db_url. path( ) , "" ) ;
638
+ assert_eq ! ( db_url. as_str( ) , "postgres://postgres@localhost" ) ;
639
+ db_url. set_path ( "foo" ) ;
640
+ assert_eq ! ( db_url. path( ) , "/foo" ) ;
641
+ assert_eq ! ( db_url. as_str( ) , "postgres://postgres@localhost/foo" ) ;
642
+ db_url. set_path ( "/bar" ) ;
643
+ assert_eq ! ( db_url. path( ) , "/bar" ) ;
644
+ assert_eq ! ( db_url. as_str( ) , "postgres://postgres@localhost/bar" ) ;
645
+ }
646
+
647
+ #[ test]
648
+ fn test_non_special_path3 ( ) {
649
+ let mut db_url = url:: Url :: parse ( "postgres://postgres@localhost/" ) . unwrap ( ) ;
650
+ assert_eq ! ( db_url. as_str( ) , "postgres://postgres@localhost/" ) ;
651
+ db_url. set_path ( "/" ) ;
652
+ assert_eq ! ( db_url. as_str( ) , "postgres://postgres@localhost/" ) ;
653
+ assert_eq ! ( db_url. path( ) , "/" ) ;
654
+ db_url. set_path ( "/foo" ) ;
655
+ assert_eq ! ( db_url. as_str( ) , "postgres://postgres@localhost/foo" ) ;
656
+ assert_eq ! ( db_url. path( ) , "/foo" ) ;
657
+ }
0 commit comments