diff --git a/crates/clash-verge-task/tests/timers.rs b/crates/clash-verge-task/tests/timers.rs index 2cd83241f..4a4f2331c 100644 --- a/crates/clash-verge-task/tests/timers.rs +++ b/crates/clash-verge-task/tests/timers.rs @@ -123,6 +123,7 @@ async fn an_idle_timer_with_a_changed_interval_fires_after_the_new_first_delay() timers.apply(HashMap::from([("a".to_owned(), plan(MINUTE, MINUTE))])), vec![TimerChange::Updated("a".to_owned())] ); + assert!(nothing_due(&mut timers).await, "a changed timer does not fire at once"); tokio::time::advance(MINUTE).await; assert_eq!( take_expired(&mut timers).await.as_deref(), @@ -203,9 +204,18 @@ async fn an_interval_changed_during_a_run_is_reported_and_used_on_finish() { ); assert!(nothing_due(&mut timers).await); assert_eq!(timers.interval(&"a".to_owned()), Some(5 * MINUTE)); + + // The new plan's first delay is not a fire time while the run is still in flight. + tokio::time::advance(5 * MINUTE).await; + assert!( + nothing_due(&mut timers).await, + "a changed interval must not queue a second run beside the one in flight" + ); + assert!(!timers.finish(&"a".to_owned())); tokio::time::advance(5 * MINUTE - Duration::from_secs(1)).await; assert!(nothing_due(&mut timers).await); tokio::time::advance(Duration::from_secs(1)).await; assert_eq!(take_expired(&mut timers).await.as_deref(), Some("a")); + assert!(nothing_due(&mut timers).await, "exactly one run after the change"); }