(name: &str)
| 275 | use crate::event::alert::types::{AlertCondition, CompareOp}; |
| 276 | |
| 277 | fn make_alert(name: &str) -> AlertDef { |
| 278 | AlertDef { |
| 279 | tenant_id: 1, |
| 280 | name: name.into(), |
| 281 | collection: "sensor_data".into(), |
| 282 | where_filter: Some("device_type = 'compressor'".into()), |
| 283 | condition: AlertCondition { |
| 284 | agg_func: "avg".into(), |
| 285 | column: "temperature".into(), |
| 286 | op: CompareOp::Gt, |
| 287 | threshold: 90.0, |
| 288 | }, |
| 289 | group_by: vec!["device_id".into()], |
| 290 | window_ms: 300_000, |
| 291 | fire_after: 3, |
| 292 | recover_after: 2, |
| 293 | severity: "critical".into(), |
| 294 | notify_targets: Vec::new(), |
| 295 | enabled: true, |
| 296 | owner: "admin".into(), |
| 297 | created_at: 0, |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | #[test] |
| 302 | fn next_interval_uses_shortest() { |
no outgoing calls