cargo/tests/testsuite/net_config.rs

75 lines
1.6 KiB
Rust
Raw Normal View History

2019-11-25 02:42:45 +00:00
//! Tests for network configuration.
use cargo_test_support::project;
#[cargo_test]
fn net_retry_loads_from_config() {
let p = project()
2018-03-14 15:17:44 +00:00
.file(
"Cargo.toml",
r#"
[package]
2020-09-27 00:59:58 +00:00
name = "foo"
version = "0.0.1"
authors = []
2020-09-27 00:59:58 +00:00
[dependencies.bar]
git = "http://127.0.0.1:11/foo/bar"
"#,
2018-12-08 11:19:47 +00:00
)
.file("src/main.rs", "")
2018-03-14 15:17:44 +00:00
.file(
".cargo/config",
r#"
2020-09-27 00:59:58 +00:00
[net]
retry=1
[http]
timeout=1
"#,
2018-12-08 11:19:47 +00:00
)
.build();
p.cargo("check -v")
.with_status(101)
.with_stderr_contains(
2018-03-14 15:17:44 +00:00
"[WARNING] spurious network error \
(1 tries remaining): [..]",
2018-12-08 11:19:47 +00:00
)
.run();
}
#[cargo_test]
fn net_retry_git_outputs_warning() {
let p = project()
2018-03-14 15:17:44 +00:00
.file(
"Cargo.toml",
r#"
[package]
2020-09-27 00:59:58 +00:00
name = "foo"
version = "0.0.1"
authors = []
2020-09-27 00:59:58 +00:00
[dependencies.bar]
git = "http://127.0.0.1:11/foo/bar"
"#,
2018-12-08 11:19:47 +00:00
)
.file(
2018-03-14 15:17:44 +00:00
".cargo/config",
r#"
2020-09-27 00:59:58 +00:00
[http]
timeout=1
"#,
2018-12-08 11:19:47 +00:00
)
.file("src/main.rs", "")
.build();
p.cargo("check -v -j 1")
.with_status(101)
.with_stderr_contains(
"[WARNING] spurious network error \
(2 tries remaining): [..]",
2018-12-08 11:19:47 +00:00
)
.with_stderr_contains("[WARNING] spurious network error (1 tries remaining): [..]")
.run();
}