Skip to content

Commit 8668136

Browse files
committed
chore: add tests for github pull request's url as dependency
1 parent 8c4a25c commit 8668136

File tree

2 files changed

+88
-0
lines changed

2 files changed

+88
-0
lines changed

tests/testsuite/bad_config.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2259,6 +2259,42 @@ Caused by:
22592259
.run();
22602260
}
22612261

2262+
#[cargo_test(public_network_test)]
2263+
fn github_pull_request_url() {
2264+
let p = project()
2265+
.file(
2266+
"Cargo.toml",
2267+
r#"
2268+
[package]
2269+
name = "foo"
2270+
version = "0.0.0"
2271+
edition = "2015"
2272+
authors = []
2273+
2274+
[dependencies.bar]
2275+
git = "https://github.com/rust-lang/does-not-exist/pull/123"
2276+
"#,
2277+
)
2278+
.file("src/lib.rs", "")
2279+
.build();
2280+
2281+
p.cargo("check -v")
2282+
.with_status(101)
2283+
.with_stderr_data(str![[r#"
2284+
[UPDATING] git repository `https://github.com/rust-lang/does-not-exist/pull/123`
2285+
...
2286+
[ERROR] failed to get `bar` as a dependency of package `foo v0.0.0 ([ROOT]/foo)`
2287+
2288+
Caused by:
2289+
failed to load source for dependency `bar`
2290+
2291+
Caused by:
2292+
Unable to update https://github.com/rust-lang/does-not-exist/pull/123
2293+
...
2294+
"#]])
2295+
.run();
2296+
}
2297+
22622298
#[cargo_test]
22632299
fn fragment_in_git_url() {
22642300
let p = project()

tests/testsuite/patch.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,58 @@ fn patch_to_git() {
357357
.run();
358358
}
359359

360+
#[cargo_test(public_network_test)]
361+
fn patch_to_git_pull_request() {
362+
Package::new("bar", "0.1.0").publish();
363+
364+
let p = project()
365+
.file(
366+
"Cargo.toml",
367+
r#"
368+
[package]
369+
name = "foo"
370+
version = "0.0.1"
371+
edition = "2015"
372+
authors = []
373+
374+
[dependencies]
375+
bar = "0.1"
376+
377+
[patch.crates-io]
378+
bar = { git = 'https://github.com/rust-lang/does-not-exist/pull/123' }
379+
"#,
380+
)
381+
.file(
382+
"src/lib.rs",
383+
"extern crate bar; pub fn foo() { bar::bar(); }",
384+
)
385+
.build();
386+
387+
p.cargo("check -v")
388+
.with_status(101)
389+
.with_stderr_data(format!(
390+
r#"[UPDATING] git repository `https://github.com/rust-lang/does-not-exist/pull/123`
391+
...
392+
[ERROR] failed to load source for dependency `bar`
393+
394+
Caused by:
395+
Unable to update https://github.com/rust-lang/does-not-exist/pull/123
396+
397+
Caused by:
398+
failed to clone into: [ROOT]/home/.cargo/git/db/123-[HASH]
399+
400+
Caused by:
401+
network failure seems to have happened
402+
if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
403+
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
404+
405+
Caused by:
406+
...
407+
"#
408+
))
409+
.run();
410+
}
411+
360412
#[cargo_test]
361413
fn unused() {
362414
Package::new("bar", "0.1.0").publish();

0 commit comments

Comments
 (0)