Skip to content

Commit

Permalink
Add verification that an crate has been published to the correct loca…
Browse files Browse the repository at this point in the history
…tion.
  • Loading branch information
cswindle committed Oct 31, 2017
1 parent 276e902 commit 4ef8f55
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion tests/alt-registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ extern crate cargotest;
extern crate hamcrest;

use cargotest::ChannelChanger;
use cargotest::support::registry::{self, Package};
use cargotest::support::registry::{self, Package, alt_dl_path};
use cargotest::support::{project, execs};
use hamcrest::assert_that;

Expand Down Expand Up @@ -308,4 +308,7 @@ fn publish_to_alt_registry() {
assert_that(p.cargo("publish").masquerade_as_nightly_cargo()
.arg("--registry").arg("alternative").arg("-Zunstable-options"),
execs().with_status(0));

// Ensure that the crate is uploaded
assert!(alt_dl_path().join("api/v1/crates/new").exists());
}
9 changes: 6 additions & 3 deletions tests/cargotest/support/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pub fn dl_path() -> PathBuf { paths::root().join("dl") }
pub fn dl_url() -> Url { Url::from_file_path(&*dl_path()).ok().unwrap() }
pub fn alt_registry_path() -> PathBuf { paths::root().join("alternative-registry") }
pub fn alt_registry() -> Url { Url::from_file_path(&*alt_registry_path()).ok().unwrap() }
pub fn alt_dl_path() -> PathBuf { paths::root().join("alt_dl") }
pub fn alt_dl_url() -> Url { Url::from_file_path(&*alt_dl_path()).ok().unwrap() }

pub struct Package {
name: String,
Expand Down Expand Up @@ -75,9 +77,9 @@ pub fn init() {
repo(&alt_registry_path())
.file("config.json", &format!(r#"
{{"dl":"{0}","api":"{0}"}}
"#, dl_url()))
"#, alt_dl_url()))
.build();
fs::create_dir_all(dl_path().join("api/v1/crates")).unwrap();
fs::create_dir_all(alt_dl_path().join("api/v1/crates")).unwrap();
}

impl Package {
Expand Down Expand Up @@ -299,7 +301,8 @@ impl Package {
registry_path().join(format!("{}-{}.crate", self.name,
self.vers))
} else {
dl_path().join(&self.name).join(&self.vers).join("download")
let dl_path = if self.alternative { alt_dl_path() } else { dl_path() };
dl_path.join(&self.name).join(&self.vers).join("download")
}
}
}
Expand Down

0 comments on commit 4ef8f55

Please sign in to comment.