Skip to content

Commit 4ef8f55

Browse files
committed
Add verification that an crate has been published to the correct location.
1 parent 276e902 commit 4ef8f55

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

tests/alt-registry.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ extern crate cargotest;
22
extern crate hamcrest;
33

44
use cargotest::ChannelChanger;
5-
use cargotest::support::registry::{self, Package};
5+
use cargotest::support::registry::{self, Package, alt_dl_path};
66
use cargotest::support::{project, execs};
77
use hamcrest::assert_that;
88

@@ -308,4 +308,7 @@ fn publish_to_alt_registry() {
308308
assert_that(p.cargo("publish").masquerade_as_nightly_cargo()
309309
.arg("--registry").arg("alternative").arg("-Zunstable-options"),
310310
execs().with_status(0));
311+
312+
// Ensure that the crate is uploaded
313+
assert!(alt_dl_path().join("api/v1/crates/new").exists());
311314
}

tests/cargotest/support/registry.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ pub fn dl_path() -> PathBuf { paths::root().join("dl") }
2020
pub fn dl_url() -> Url { Url::from_file_path(&*dl_path()).ok().unwrap() }
2121
pub fn alt_registry_path() -> PathBuf { paths::root().join("alternative-registry") }
2222
pub fn alt_registry() -> Url { Url::from_file_path(&*alt_registry_path()).ok().unwrap() }
23+
pub fn alt_dl_path() -> PathBuf { paths::root().join("alt_dl") }
24+
pub fn alt_dl_url() -> Url { Url::from_file_path(&*alt_dl_path()).ok().unwrap() }
2325

2426
pub struct Package {
2527
name: String,
@@ -75,9 +77,9 @@ pub fn init() {
7577
repo(&alt_registry_path())
7678
.file("config.json", &format!(r#"
7779
{{"dl":"{0}","api":"{0}"}}
78-
"#, dl_url()))
80+
"#, alt_dl_url()))
7981
.build();
80-
fs::create_dir_all(dl_path().join("api/v1/crates")).unwrap();
82+
fs::create_dir_all(alt_dl_path().join("api/v1/crates")).unwrap();
8183
}
8284

8385
impl Package {
@@ -299,7 +301,8 @@ impl Package {
299301
registry_path().join(format!("{}-{}.crate", self.name,
300302
self.vers))
301303
} else {
302-
dl_path().join(&self.name).join(&self.vers).join("download")
304+
let dl_path = if self.alternative { alt_dl_path() } else { dl_path() };
305+
dl_path.join(&self.name).join(&self.vers).join("download")
303306
}
304307
}
305308
}

0 commit comments

Comments
 (0)