Skip to content

Commit efce094

Browse files
committed
test(alt_registry): show current behavior allows \registry-index\ in user manifests
1 parent 19678fc commit efce094

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

tests/testsuite/alt_registry.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,61 @@ Caused by:
260260
.run();
261261
}
262262

263+
#[cargo_test]
264+
fn registry_index_not_allowed_in_user_manifests() {
265+
registry::alt_init();
266+
Package::new("bar", "0.1.0").alternative(true).publish();
267+
268+
let p = project()
269+
.file(
270+
"Cargo.toml",
271+
r#"
272+
[package]
273+
name = "foo"
274+
version = "0.0.0"
275+
edition = "2015"
276+
authors = []
277+
278+
[dependencies]
279+
bar = { version = "0.1.0", registry-index = "https://example.com/index" }
280+
"#,
281+
)
282+
.file("src/lib.rs", "")
283+
.build();
284+
285+
// FIXME: This currently allows `registry-index` which is a bug.
286+
// It should error during manifest parsing because `registry-index` is for internal use only.
287+
// Instead, it tries to fetch from the URL and fails with a network error.
288+
p.cargo("check")
289+
.with_status(101)
290+
.with_stderr_data(str![[r#"
291+
[UPDATING] `https://example.com/index` index
292+
[WARNING] spurious network error (3 tries remaining): unexpected http status code: 404; class=Http (34)
293+
[WARNING] spurious network error (2 tries remaining): unexpected http status code: 404; class=Http (34)
294+
[WARNING] spurious network error (1 try remaining): unexpected http status code: 404; class=Http (34)
295+
[ERROR] failed to get `bar` as a dependency of package `foo v0.0.0 ([ROOT]/foo)`
296+
297+
Caused by:
298+
failed to load source for dependency `bar`
299+
300+
Caused by:
301+
Unable to update registry `https://example.com/index`
302+
303+
Caused by:
304+
failed to fetch `https://example.com/index`
305+
306+
Caused by:
307+
network failure seems to have happened
308+
if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
309+
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
310+
311+
Caused by:
312+
unexpected http status code: 404; class=Http (34)
313+
314+
"#]])
315+
.run();
316+
}
317+
263318
#[cargo_test]
264319
fn cannot_publish_to_crates_io_with_registry_dependency() {
265320
let crates_io = registry::init();

0 commit comments

Comments
 (0)