dotfiles/agent/tests/task_health.rs

19 lines
630 B
Rust
Raw Normal View History

use prymn_agent::system::{health::HealthMonitor, task::TaskBuilder};
#[tokio::test]
async fn task_is_gone_from_health_monitor_when_complete() {
let health_monitor = HealthMonitor::new();
let health_recv = health_monitor.monitor();
let mut task_recv = TaskBuilder::new("test task".to_owned())
.health_monitor(health_monitor)
.add_step(async { "foo" })
.add_step(async { "bar" })
.build()
.into_background();
assert_eq!(task_recv.recv().await.unwrap(), "foo");
assert_eq!(task_recv.recv().await.unwrap(), "bar");
assert!(health_recv.borrow().tasks().is_empty());
}