dotfiles/agent/tests/task_health.rs
2023-11-14 17:42:47 +02:00

18 lines
622 B
Rust

use prymn_agent::{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());
}