commit 8c27088a83e5388d877c5302519f9f8b14af4f94
parent 52244c296262d1f585bb9344a874d013cc5acc73
Author: triesap <triesap@radroots.dev>
Date: Mon, 19 Jan 2026 18:31:39 +0000
app: add key map health check
- add health check for datastore key map validation
- map config errors into health results
- export key map health check helper
- add unit test for invalid map reporting
Diffstat:
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/app/src/health.rs b/app/src/health.rs
@@ -73,9 +73,24 @@ impl AppHealthReport {
}
}
+use crate::{app_key_maps_validate, AppKeyMapConfig};
+
+pub fn app_health_check_key_maps(key_maps: &AppKeyMapConfig) -> AppHealthCheckResult {
+ match app_key_maps_validate(key_maps) {
+ Ok(()) => AppHealthCheckResult::ok(),
+ Err(err) => AppHealthCheckResult::error(err.to_string()),
+ }
+}
+
#[cfg(test)]
mod tests {
- use super::{AppHealthCheckResult, AppHealthCheckStatus, AppHealthReport};
+ use super::{
+ app_health_check_key_maps,
+ AppHealthCheckResult,
+ AppHealthCheckStatus,
+ AppHealthReport,
+ };
+ use crate::AppKeyMapConfig;
#[test]
fn health_status_as_str() {
@@ -104,4 +119,15 @@ mod tests {
assert_eq!(report.datastore_roundtrip.status, AppHealthCheckStatus::Skipped);
assert_eq!(report.keystore.status, AppHealthCheckStatus::Skipped);
}
+
+ #[test]
+ fn health_check_key_maps_reports_errors() {
+ let empty = AppKeyMapConfig::empty();
+ let result = app_health_check_key_maps(&empty);
+ assert_eq!(result.status, AppHealthCheckStatus::Error);
+ assert_eq!(
+ result.message.as_deref(),
+ Some("error.app.config.key_map_missing")
+ );
+ }
}
diff --git a/app/src/lib.rs b/app/src/lib.rs
@@ -20,6 +20,7 @@ pub use bootstrap::{
pub use context::{app_context, AppContext};
pub use data::{AppAppData, AppConfigData, AppConfigRole};
pub use health::{
+ app_health_check_key_maps,
AppHealthCheckResult,
AppHealthCheckStatus,
AppHealthReport,