Ajout de tests unitaires et mise à jour du rapport de couverture
Ajout de tests unitaires pour les fonctions de gestion des processus et des protocoles de transport. Mise à jour de la configuration de couverture pour générer un rapport JSON au lieu de HTML. Les tests couvrent les formats de chaînes OS, les propriétés des structures ProcessPortInfo et TransportProtocol, ainsi que les comportements de base de la fonction find_process_using_port.
This commit is contained in:
27
src/lib.rs
27
src/lib.rs
@@ -18,6 +18,33 @@
|
||||
pub mod ip_utils;
|
||||
|
||||
pub use ip_utils::guess_local_ip;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_get_os_string_format() {
|
||||
let os = get_os_string();
|
||||
assert!(!os.is_empty());
|
||||
assert!(os.contains("/"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_os_string_contains_os_type() {
|
||||
let os = get_os_string();
|
||||
// Les types d'OS retournés par os_info peuvent varier, on vérifie juste le format
|
||||
let parts: Vec<&str> = os.split('/').collect();
|
||||
assert_eq!(
|
||||
parts.len(),
|
||||
2,
|
||||
"OS string should have format 'Type/Version'"
|
||||
);
|
||||
assert!(!parts[0].is_empty(), "OS type should not be empty");
|
||||
assert!(!parts[1].is_empty(), "OS version should not be empty");
|
||||
}
|
||||
}
|
||||
|
||||
pub mod process;
|
||||
pub use process::{find_process_using_port, ProcessPortInfo, TransportProtocol};
|
||||
/// Retourne une chaîne décrivant le système d'exploitation et sa version.
|
||||
|
||||
Reference in New Issue
Block a user