Skip to content

Commit

Permalink
chore: test repository-url
Browse files Browse the repository at this point in the history
  • Loading branch information
Gankra committed Jun 17, 2024
1 parent 567d9ee commit a9a66c6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
23 changes: 22 additions & 1 deletion axoproject/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use camino::{Utf8Path, Utf8PathBuf};

use crate::{changelog::ChangelogInfo, errors::AxoprojectError, Version, WorkspaceKind};
use crate::{
changelog::ChangelogInfo, errors::AxoprojectError, PackageIdx, Version, WorkspaceKind,
};

#[cfg(feature = "cargo-projects")]
#[test]
Expand Down Expand Up @@ -602,6 +604,8 @@ fn generic_workspace_check<'a>(path: impl Into<&'a Utf8Path>) {
project.root_auto_includes.changelog.as_deref().unwrap(),
"root fake changelog!",
);
// repository is inconsistent, so this should be Err
assert!(project.repository_url(None).is_err());

{
let package = &project.package_info[0];
Expand All @@ -611,6 +615,7 @@ fn generic_workspace_check<'a>(path: impl Into<&'a Utf8Path>) {
assert_eq!(binary, "main");
assert!(package.manifest_path.exists());
assert!(package.manifest_path != project.manifest_path);
// Inner package defines its own auto_includes
check_file(
package.readme_file.as_deref().unwrap(),
"inner fake readme!",
Expand All @@ -620,6 +625,14 @@ fn generic_workspace_check<'a>(path: impl Into<&'a Utf8Path>) {
package.changelog_file.as_deref().unwrap(),
"inner fake changelog!",
);
// repository should yield this one, so this should faile
assert_eq!(
project
.repository_url(Some(&[PackageIdx(0)]))
.unwrap()
.unwrap(),
"https://github.com/mistydemeo/testprog1"
);
}

{
Expand All @@ -630,12 +643,20 @@ fn generic_workspace_check<'a>(path: impl Into<&'a Utf8Path>) {
assert_eq!(binary, "main");
assert!(package.manifest_path.exists());
assert!(package.manifest_path != project.manifest_path);
// Inner package inherits root auto_includes
check_file(package.readme_file.as_deref().unwrap(), "root fake readme!");
check_file(&package.license_files[0], "root fake license!");
check_file(
package.changelog_file.as_deref().unwrap(),
"root fake changelog!",
);
assert_eq!(
project
.repository_url(Some(&[PackageIdx(1)]))
.unwrap()
.unwrap(),
"https://github.com/mistydemeo/testprog2"
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "generic1"
description = "A test of a C program for cargo-dist"
version = "0.0.1"
license = "WTFPL"
repository = "https://github.com/mistydemeo/testprog"
repository = "https://github.com/mistydemeo/testprog1"
binaries = ["main"]
build-command = ["make"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "generic2"
description = "A test of a C program for cargo-dist"
version = "0.0.1"
license = "WTFPL"
repository = "https://github.com/mistydemeo/testprog"
repository = "https://github.com/mistydemeo/testprog2"
binaries = ["main"]
build-command = ["make"]

Expand Down
2 changes: 1 addition & 1 deletion cargo-dist/src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<'a> DistGraphBuilder<'a> {
hosting: Option<Vec<HostingStyle>>,
ci: Option<Vec<CiStyle>>,
) -> DistResult<()> {
self.inner.hosting = select_hosting(&self.workspace, announcing, hosting, ci.as_deref());
self.inner.hosting = select_hosting(self.workspace, announcing, hosting, ci.as_deref());
// If we don't think we can host things, don't bother
let Some(hosting) = &self.inner.hosting else {
return Ok(());
Expand Down

0 comments on commit a9a66c6

Please sign in to comment.