Ver Fonte

url: test that setting scheme to file with host fails (see #278)

Dirkjan Ochtman há 6 anos atrás
pai
commit
7b8b8416c3
1 ficheiros alterados com 8 adições e 0 exclusões
  1. 8 0
      url/tests/unit.rs

+ 8 - 0
url/tests/unit.rs

@@ -654,3 +654,11 @@ fn test_non_special_path3() {
     assert_eq!(db_url.as_str(), "postgres://postgres@localhost/foo");
     assert_eq!(db_url.path(), "/foo");
 }
+
+#[test]
+fn test_set_scheme_to_file_with_host() {
+    let mut url: Url = "http://localhost:6767/foo/bar".parse().unwrap();
+    let result = url.set_scheme("file");
+    assert_eq!(url.to_string(), "http://localhost:6767/foo/bar");
+    assert_eq!(result, Err(()));
+}