This commit is contained in:
Mateusz Gruszczyński committed 2026-09-04 11:00:15 +02:00
1 parent 8152e63d63
commit 236540e0f0
27 files changed
+557 -102

No files matched your search

+25
View File
@@ -11,6 +11,31 @@ mod tests {
assert_eq!(effective_sensor_stale_after_seconds(120_000, 600), 86_400);
}
#[test]
fn control_plan_semantic_equality_ignores_only_generation_timestamp() {
let generated_at = Utc.with_ymd_and_hms(2026, 9, 4, 8, 0, 0).unwrap();
let left = ControlPlan {
generated_at: generated_at.clone(),
house_mode: "cool".into(),
house_preset: Some("comfort".into()),
house_power: true,
outdoor_temperature: Some(24.0),
control_strategy: "thermostat".into(),
night_mode_active: false,
night_mode_start: "22:00".into(),
night_mode_end: "06:00".into(),
night_mode_max_fan_speed: 2,
next_events: Vec::new(),
zones: Vec::new(),
rules: Vec::new(),
};
let mut right = left.clone();
right.generated_at = generated_at + chrono::Duration::seconds(30);
assert!(control_plans_semantically_equal(&left, &right).unwrap());
right.house_mode = "heat".into();
assert!(!control_plans_semantically_equal(&left, &right).unwrap());
}
#[test]
fn overnight_schedule_works() {
let now = Utc.with_ymd_and_hms(2025, 1, 7, 1, 0, 0).unwrap().with_timezone(&Local); // Tuesday