From 3ad0652b27231c00518882c6c23895851bd138c2 Mon Sep 17 00:00:00 2001 From: objz Date: Sat, 21 Feb 2026 14:32:19 +0100 Subject: [PATCH] test(net): add maven_coord_to_path and detect_java_path tests --- src/net/mod.rs | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/src/net/mod.rs b/src/net/mod.rs index 53c4599..1a56328 100644 --- a/src/net/mod.rs +++ b/src/net/mod.rs @@ -157,3 +157,58 @@ pub fn maven_coord_to_path(coord: &str) -> Option { _ => None, } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn maven_3_part_coord() { + assert_eq!( + maven_coord_to_path("org.example:artifact:1.0"), + Some("org/example/artifact/1.0/artifact-1.0.jar".to_string()) + ); + } + + #[test] + fn maven_4_part_coord_with_classifier() { + assert_eq!( + maven_coord_to_path("org.example:artifact:1.0:sources"), + Some("org/example/artifact/1.0/artifact-1.0-sources.jar".to_string()) + ); + } + + #[test] + fn maven_nested_group() { + assert_eq!( + maven_coord_to_path("com.google.code.gson:gson:2.10"), + Some("com/google/code/gson/gson/2.10/gson-2.10.jar".to_string()) + ); + } + + #[test] + fn maven_invalid_too_few_parts() { + assert_eq!(maven_coord_to_path("org.example:artifact"), None); + } + + #[test] + fn maven_invalid_too_many_parts() { + assert_eq!(maven_coord_to_path("a:b:c:d:e"), None); + } + + #[test] + fn maven_invalid_single_part() { + assert_eq!(maven_coord_to_path("just-a-string"), None); + } + + #[test] + fn maven_empty_string() { + assert_eq!(maven_coord_to_path(""), None); + } + + #[test] + fn detect_java_falls_back_to_java() { + let result = detect_java_path(); + assert!(!result.is_empty()); + } +}