Files
hms/crates/erp-health/tests/alert_noise_integration.rs
iven 2e9f6621a3 test(health): 告警降噪集成测试骨架
4 个 Testcontainers 测试用例(忽略状态)覆盖:
患者级升级阈值 + 系统级聚合窗口 + critical 不聚合 + 完整流程
2026-05-04 02:54:17 +08:00

52 lines
1.7 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/// 告警降噪集成测试骨架。
///
/// 纯逻辑单元测试在 alert_noise_reducer::tests 中。
/// 以下集成测试需要 Testcontainers PostgreSQL 环境。
use erp_health::service::alert_noise_reducer;
/// 验证 severity_rank 排序一致性
#[test]
fn severity_rank_consistency_via_module() {
// 间接验证alert_noise_reducer 模块可被外部 crate 引用
// 实际逻辑测试在 lib 内的 tests 模块中
}
/// 验证患者级升级条件
#[tokio::test]
#[ignore = "需要 Testcontainers 环境"]
async fn patient_escalation_requires_threshold_alerts() {
// 1. 创建患者和 2 条低级别告警
// 2. 调用 apply_noise_reduction("medium")
// 3. 验证未升级
// 4. 再创建 1 条低级别告警(达到阈值 3
// 5. 调用 apply_noise_reduction("medium")
// 6. 验证升级为 "high"
}
/// 验证系统级聚合
#[tokio::test]
#[ignore = "需要 Testcontainers 环境"]
async fn system_aggregation_suppresses_within_window() {
// 1. 创建一条告警
// 2. 立即调用 check_system_aggregation
// 3. 验证 should_suppress = true
}
/// 验证 critical 告警不被聚合
#[tokio::test]
#[ignore = "需要 Testcontainers 环境"]
async fn critical_alerts_never_suppressed() {
// 1. 创建多条告警(含 critical
// 2. 调用 apply_noise_reduction("critical")
// 3. 验证 is_suppressed = false
}
/// 验证完整降噪流程:低级告警多次触发后升级 + 聚合
#[tokio::test]
#[ignore = "需要 Testcontainers 环境"]
async fn full_noise_reduction_flow() {
// 1. 创建 3 条低级告警
// 2. 第 4 次触发 apply_noise_reduction("low") → 升级为 "medium"
// 3. 短时间内再次触发 → 被聚合抑制
}