test(net): add maven_coord_to_path and detect_java_path tests
This commit is contained in:
1 parent
638b14c921
commit
3ad0652b27
1 file changed
+55
@@ -157,3 +157,58 @@ pub fn maven_coord_to_path(coord: &str) -> Option<String> {
|
||||
_ => 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());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user