Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(cron): cover agent tick health reporting

Steven Enamakel17091db4f507
diff --git a/crates/openhuman-core/src/cron/scheduler_tests.rs b/crates/openhuman-core/src/cron/scheduler_tests.rs
index dea7b60edd..80184d947d 100644
--- a/crates/openhuman-core/src/cron/scheduler_tests.rs
+++ b/crates/openhuman-core/src/cron/scheduler_tests.rs
@@ -313,3 +313,25 @@ async fn a_pipeline_reports_its_last_stage_rather_than_pipefail() {
a failure and re-status every existing job with a pipeline in it: {output}"
);
}
+
+#[tokio::test]
+async fn an_agent_pass_polls_with_its_own_config_and_reports_health() {
+ let tmp = TempDir::new().unwrap();
+ let config = test_config(&tmp).await;
+ let mut health = None;
+ tick_agent_scope(&config, &mut health).await;
+ assert_eq!(health, Some(true), "a successful poll reports healthy");
+}
+
+#[tokio::test]
+async fn tick_agents_without_a_backend_leaves_the_health_tracker_alone() {
+ // The lib test binary installs no storage backend, so no agent is visited.
+ if crate::storage::installed().is_some() {
+ return;
+ }
+ let tmp = TempDir::new().unwrap();
+ let config = test_config(&tmp).await;
+ let mut health = Some(false);
+ tick_agents(&config, &mut health).await;
+ assert_eq!(health, Some(false));
+}
diff --git a/crates/openhuman-core/src/security/devices/owner_tests.rs b/crates/openhuman-core/src/security/devices/owner_tests.rs
index 4476e9adf8..4a4575c241 100644
--- a/crates/openhuman-core/src/security/devices/owner_tests.rs
+++ b/crates/openhuman-core/src/security/devices/owner_tests.rs
@@ -55,14 +55,13 @@ fn scoped_config(dir: &std::path::Path) -> crate::config::Config {
async fn a_device_found_in_the_local_scope_belongs_to_local_and_is_remembered() {
let tmp = tempfile::tempdir().unwrap();
let config = scoped_config(tmp.path());
- super::super::store::insert_device(&config, "owner-test-found", "label", "pk", "hash")
- .unwrap();
+ super::super::store::insert_device(&config, "owner-test-found", "label", "pk", "hash").unwrap();
let context = crate::core::runtime::CoreContext::for_test_with_config(
crate::core::runtime::DomainSet::full(),
config,
);
- let owner = crate::core::runtime::CoreContext::scope(context, owner_of("owner-test-found", None))
- .await;
+ let owner =
+ crate::core::runtime::CoreContext::scope(context, owner_of("owner-test-found", None)).await;
assert_eq!(owner, None);
assert_eq!(cached("owner-test-found"), Some(None));
}
@@ -74,8 +73,9 @@ async fn a_channel_no_scope_knows_is_local_and_not_remembered() {
crate::core::runtime::DomainSet::full(),
scoped_config(tmp.path()),
);
- let owner = crate::core::runtime::CoreContext::scope(context, owner_of("owner-test-missing", None))
- .await;
+ let owner =
+ crate::core::runtime::CoreContext::scope(context, owner_of("owner-test-missing", None))
+ .await;
assert_eq!(owner, None);
assert_eq!(cached("owner-test-missing"), None);
}