Fix CI
This commit is contained in:
parent
8a45bc7367
commit
9151562b6b
3 changed files with 17 additions and 14 deletions
|
|
@ -21,11 +21,11 @@ fn expand_tilde(path: &str) -> String {
|
||||||
if let Some(home) = dirs::home_dir() {
|
if let Some(home) = dirs::home_dir() {
|
||||||
return path.replacen("~", &home.to_string_lossy(), 1);
|
return path.replacen("~", &home.to_string_lossy(), 1);
|
||||||
}
|
}
|
||||||
} else if path == "~" {
|
} else if path == "~"
|
||||||
if let Some(home) = dirs::home_dir() {
|
&& let Some(home) = dirs::home_dir()
|
||||||
|
{
|
||||||
return home.to_string_lossy().into_owned();
|
return home.to_string_lossy().into_owned();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
path.to_string()
|
path.to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -397,13 +397,13 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_format_clock_time() {
|
fn test_format_clock_time() {
|
||||||
let dt = Local.with_ymd_and_hms(2025, 12, 25, 14, 30, 45).unwrap();
|
let dt = Local.with_ymd_and_hms(2025, 12, 25, 14, 30, 45).unwrap();
|
||||||
assert_eq!(format_clock_time(&dt), "02:30 PM");
|
assert_eq!(format_clock_time(&dt), " 2:30 PM");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_format_datetime_full() {
|
fn test_format_datetime_full() {
|
||||||
let dt = Local.with_ymd_and_hms(2025, 12, 25, 14, 30, 45).unwrap();
|
let dt = Local.with_ymd_and_hms(2025, 12, 25, 14, 30, 45).unwrap();
|
||||||
assert_eq!(format_datetime_full(&dt), "2025-12-25 14:30:45");
|
assert_eq!(format_datetime_full(&dt), "2025-12-25 2:30:45 PM");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -141,23 +141,25 @@ fn test_warning_emission() {
|
||||||
engine.start_session(plan, now, now_mono);
|
engine.start_session(plan, now, now_mono);
|
||||||
|
|
||||||
// No warnings at start
|
// No warnings at start
|
||||||
let events = engine.tick(now_mono);
|
let events = engine.tick(now_mono, now);
|
||||||
assert!(events.is_empty());
|
assert!(events.is_empty());
|
||||||
|
|
||||||
// At 6 seconds (4 seconds remaining), 5-second warning should fire
|
// At 6 seconds (4 seconds remaining), 5-second warning should fire
|
||||||
let at_6s = now_mono + Duration::from_secs(6);
|
let at_6s_mono = now_mono + Duration::from_secs(6);
|
||||||
let events = engine.tick(at_6s);
|
let at_6s = now + chrono::Duration::seconds(6);
|
||||||
|
let events = engine.tick(at_6s_mono, at_6s);
|
||||||
assert_eq!(events.len(), 1);
|
assert_eq!(events.len(), 1);
|
||||||
assert!(matches!(&events[0], CoreEvent::Warning { threshold_seconds: 5, .. }));
|
assert!(matches!(&events[0], CoreEvent::Warning { threshold_seconds: 5, .. }));
|
||||||
|
|
||||||
// At 9 seconds (1 second remaining), 2-second warning should fire
|
// At 9 seconds (1 second remaining), 2-second warning should fire
|
||||||
let at_9s = now_mono + Duration::from_secs(9);
|
let at_9s_mono = now_mono + Duration::from_secs(9);
|
||||||
let events = engine.tick(at_9s);
|
let at_9s = now + chrono::Duration::seconds(9);
|
||||||
|
let events = engine.tick(at_9s_mono, at_9s);
|
||||||
assert_eq!(events.len(), 1);
|
assert_eq!(events.len(), 1);
|
||||||
assert!(matches!(&events[0], CoreEvent::Warning { threshold_seconds: 2, .. }));
|
assert!(matches!(&events[0], CoreEvent::Warning { threshold_seconds: 2, .. }));
|
||||||
|
|
||||||
// Warnings shouldn't repeat
|
// Warnings shouldn't repeat
|
||||||
let events = engine.tick(at_9s);
|
let events = engine.tick(at_9s_mono, at_9s);
|
||||||
assert!(events.is_empty());
|
assert!(events.is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -180,8 +182,9 @@ fn test_session_expiry() {
|
||||||
engine.start_session(plan, now, now_mono);
|
engine.start_session(plan, now, now_mono);
|
||||||
|
|
||||||
// At 11 seconds, session should be expired
|
// At 11 seconds, session should be expired
|
||||||
let at_11s = now_mono + Duration::from_secs(11);
|
let at_11s_mono = now_mono + Duration::from_secs(11);
|
||||||
let events = engine.tick(at_11s);
|
let at_11s = now + chrono::Duration::seconds(11);
|
||||||
|
let events = engine.tick(at_11s_mono, at_11s);
|
||||||
|
|
||||||
// Should have both remaining warnings + expiry
|
// Should have both remaining warnings + expiry
|
||||||
let has_expiry = events.iter().any(|e| matches!(e, CoreEvent::ExpireDue { .. }));
|
let has_expiry = events.iter().any(|e| matches!(e, CoreEvent::ExpireDue { .. }));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue