From 5a79a6747f94188b09fd7eedb6bf605dd8989469 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 14 Mar 2026 01:01:17 +0000 Subject: [PATCH 1/2] Add unit tests for `get_name` in utilities.rs The `get_name` function was missing tests. This commit adds a test module to `src/utilities.rs` covering all key scenarios for `get_name`: valid names, fallback to url, fallback to path, error on no fallbacks, and error on all none. Co-authored-by: bashandbone <89049923+bashandbone@users.noreply.github.com> --- src/utilities.rs | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/src/utilities.rs b/src/utilities.rs index 8b5e054..b0b23e6 100644 --- a/src/utilities.rs +++ b/src/utilities.rs @@ -226,3 +226,87 @@ pub(crate) fn get_name( Err(anyhow::anyhow!("No valid name source provided")) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_get_name_valid_name() { + assert_eq!( + get_name(Some("my-repo".to_string()), None, None).unwrap(), + "my-repo" + ); + assert_eq!( + get_name( + Some(" spaced-repo ".to_string()), + None, + None + ) + .unwrap(), + "spaced-repo" + ); + } + + #[test] + fn test_get_name_empty_name_fallback_url() { + assert_eq!( + get_name( + Some(" ".to_string()), + Some("https://github.com/user/repo.git".to_string()), + None + ) + .unwrap(), + "repo" + ); + } + + #[test] + fn test_get_name_empty_name_fallback_path() { + assert_eq!( + get_name( + Some("".to_string()), + None, + Some(std::ffi::OsString::from("path/to/my-module")) + ) + .unwrap(), + "my-module" + ); + } + + #[test] + fn test_get_name_empty_name_no_fallback() { + assert!(get_name(Some(" ".to_string()), None, None).is_err()); + } + + #[test] + fn test_get_name_no_name_valid_path() { + assert_eq!( + get_name( + None, + None, + Some(std::ffi::OsString::from("another-path")) + ) + .unwrap(), + "another-path" + ); + } + + #[test] + fn test_get_name_no_name_no_path_valid_url() { + assert_eq!( + get_name( + None, + Some("git@github.com:user/another-repo.git".to_string()), + None + ) + .unwrap(), + "another-repo" + ); + } + + #[test] + fn test_get_name_all_none() { + assert!(get_name(None, None, None).is_err()); + } +} From 65c1f8345a41dfe2715c1640c7403597779ab0a3 Mon Sep 17 00:00:00 2001 From: Adam Poulemanos <89049923+bashandbone@users.noreply.github.com> Date: Fri, 13 Mar 2026 22:45:42 -0400 Subject: [PATCH 2/2] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/utilities.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utilities.rs b/src/utilities.rs index b0b23e6..458ba0f 100644 --- a/src/utilities.rs +++ b/src/utilities.rs @@ -267,7 +267,7 @@ mod tests { get_name( Some("".to_string()), None, - Some(std::ffi::OsString::from("path/to/my-module")) + Some(PathBuf::from_iter(["path", "to", "my-module"]).into_os_string()) ) .unwrap(), "my-module"