dotfiles/agent/tests/task_health.rs
Nikos Papadakis 5c64f02579 Feature: Agent Tasks ()
Reviewed-on: https://git.nikos.gg/prymn/prymn/pulls/8
Co-authored-by: Nikos Papadakis <nikos@papadakis.xyz>
Co-committed-by: Nikos Papadakis <nikos@papadakis.xyz>
2023-11-14 15:23:50 +00:00

18 lines
630 B
Rust

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());
}