Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
jneem committed May 23, 2024
1 parent 5a87535 commit e999fe7
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/testsuite/registry_overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,44 @@ fn multiversion() {
.overlay_registry(&reg.index_url(), &alt_path)
.run();
}

// Test that we can overlay on top of alternate registries, not just crates-io.
// Since the test framework only supports a single alternate registry, we repurpose
// the dummy crates-io as the registry to overlay on top.
#[cargo_test]
fn alt_registry() {
let alt = RegistryBuilder::new().http_index().alternative().build();
let crates_io = RegistryBuilder::new().build();
let crates_io_path = crates_io
.index_url()
.to_file_path()
.unwrap()
.into_os_string()
.into_string()
.unwrap();

let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
edition = "2015"
authors = []
[dependencies]
bar = { version = ">= 0.0.0", registry = "alternative" }
baz = { version = ">= 0.1.0", registry = "alternative" }
"#,
)
.file("src/main.rs", "fn main() {}")
.build();

Package::new("bar", "0.0.1").local(true).publish();
Package::new("baz", "0.1.1").alternative(true).publish();

p.cargo("check")
.overlay_registry(&alt.index_url(), &crates_io_path)
.run();
}

0 comments on commit e999fe7

Please sign in to comment.