Files
2026-05-22 11:36:51 +02:00

46 lines
1.3 KiB
Rust

use nanometrics_agent::metrics::smart;
const SMART_JSON_OK: &str = r#"{
"smart_status": {"passed": true},
"temperature": {"current": 34},
"ata_smart_attributes": {
"table": [
{"id": 5, "name": "Reallocated_Sector_Ct", "raw": {"value": 0}, "value": 200},
{"id": 9, "name": "Power_On_Hours", "raw": {"value": 4213}, "value": 77},
{"id": 177, "name": "Wear_Leveling_Count", "raw": {"value": 0}, "value": 98}
]
}
}"#;
#[test]
fn test_parse_smart_json_ok() {
let result = smart::parse_json(SMART_JSON_OK).unwrap();
assert!(result.passed);
assert_eq!(result.temperature, Some(34));
assert_eq!(result.reallocated_sectors, Some(0));
assert_eq!(result.power_on_hours, Some(4213));
assert_eq!(result.wear_level, Some(98));
}
const SMART_JSON_FAIL: &str = r#"{
"smart_status": {"passed": false},
"temperature": {"current": 52},
"ata_smart_attributes": {
"table": [
{"id": 5, "name": "Reallocated_Sector_Ct", "raw": {"value": 47}, "value": 150}
]
}
}"#;
#[test]
fn test_parse_smart_json_fail() {
let result = smart::parse_json(SMART_JSON_FAIL).unwrap();
assert!(!result.passed);
assert_eq!(result.reallocated_sectors, Some(47));
}
#[test]
fn test_smart_disponible() {
let _ = smart::is_available();
}