Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 93e6d71

Browse files
committed
realign test expectations
With invalid protocols being unusable for deliberatly making url parsing fail, we get a little more creative to do the very same.
1 parent db7577f commit 93e6d71

4 files changed

Lines changed: 8 additions & 6 deletions

File tree

git-repository/tests/fixtures/make_remote_repos.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ git init --bare bad-url-rewriting
165165
[remote "origin"]
166166
pushUrl = "file://dev/null"
167167
168-
[url "foo://"]
168+
[url "invalid:://"]
169169
pushInsteadOf = "file://"
170170
171171
[url "https://github.com/byron/"]

git-repository/tests/repository/remote.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ mod find_remote {
215215
"…but is able to replace the fetch url successfully"
216216
);
217217

218-
let expected_err_msg = "The rewritten push url \"foo://dev/null\" failed to parse";
218+
let expected_err_msg = "The rewritten push url \"invalid:://dev/null\" failed to parse";
219219
assert_eq!(
220220
repo.find_remote("origin").unwrap_err().to_string(),
221221
expected_err_msg,
@@ -237,7 +237,6 @@ mod find_remote {
237237
"it can rewrite a single url like git can"
238238
);
239239
}
240-
assert_eq!(remote.url(Direction::Push).unwrap().to_bstring(), "file://dev/null",);
241240
assert_eq!(
242241
remote.rewrite_urls().unwrap_err().to_string(),
243242
expected_err_msg,

git-url/tests/parse/invalid.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
use crate::parse::assert_failure;
22

33
#[test]
4-
fn unknown_protocol() {
5-
assert_failure("foo://host.xz/path/to/repo.git/", "Protocol \"foo\" is not supported")
4+
fn relative_path_due_to_double_colon() {
5+
assert_failure(
6+
"invalid:://host.xz/path/to/repo.git/",
7+
"Relative URLs are not permitted: \"invalid:://host.xz/path/to/repo.git/\"",
8+
)
69
}
710

811
#[test]

git-url/tests/parse/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ mod unknown {
117117
use crate::parse::{assert_url_roundtrip, url};
118118

119119
#[test]
120-
fn basic() -> crate::Result {
120+
fn any_protocol_is_supported_via_the_ext_scheme() -> crate::Result {
121121
assert_url_roundtrip(
122122
"abc://example.com/~byron/hello",
123123
url(Scheme::Ext("abc".into()), None, "example.com", None, b"/~byron/hello"),

0 commit comments

Comments
 (0)