pub(crate) mod betterstack;
pub(crate) mod fallback;
pub(crate) mod google;
pub(crate) mod instatus;
pub(crate) mod onlineornot;
pub(crate) mod status_io;
pub(crate) mod statuspage;
pub(crate) fn normalize_component_status(raw: &str) -> String {
match raw {
"OPERATIONAL" => "operational".to_string(),
"DEGRADEDPERFORMANCE" => "degraded_performance".to_string(),
"UNDERMAINTENANCE" => "under_maintenance".to_string(),
"MAJOROUTAGE" => "major_outage".to_string(),
"PARTIALOUTAGE" => "partial_outage".to_string(),
"degraded" => "degraded_performance".to_string(),
"downtime" | "outage" => "major_outage".to_string(),
other => other.to_lowercase(),
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn normalize_component_status_maps_all_platforms() {
assert_eq!(
normalize_component_status("degraded"),
"degraded_performance"
);
assert_eq!(normalize_component_status("downtime"), "major_outage");
assert_eq!(normalize_component_status("outage"), "major_outage");
assert_eq!(normalize_component_status("OPERATIONAL"), "operational");
assert_eq!(
normalize_component_status("DEGRADEDPERFORMANCE"),
"degraded_performance"
);
assert_eq!(
normalize_component_status("UNDERMAINTENANCE"),
"under_maintenance"
);
assert_eq!(normalize_component_status("MAJOROUTAGE"), "major_outage");
assert_eq!(
normalize_component_status("PARTIALOUTAGE"),
"partial_outage"
);
assert_eq!(normalize_component_status("operational"), "operational");
assert_eq!(normalize_component_status("major_outage"), "major_outage");
}
}