The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
chore(tests): add coverage for about app and thread title ops
Steven Enamakele7934f4eed06
diff --git a/crates/openhuman-core/src/platform/about_app/ops_tests.rs b/crates/openhuman-core/src/platform/about_app/ops_tests.rsindex 3aa57eebcb..fbb1be9d13 100644--- a/crates/openhuman-core/src/platform/about_app/ops_tests.rs+++ b/crates/openhuman-core/src/platform/about_app/ops_tests.rs@@ -68,3 +68,23 @@ fn reply_remix_capability_shows_disabled_when_the_memes_component_is_off() {assert_eq!(apply_components(send, &off("memes")).status, send.status);assert_eq!(apply_components(cap, &off("voice")).status, cap.status);}++#[tokio::test]+async fn an_explicit_context_decides_which_capabilities_are_disabled() {+ use crate::core::runtime::context::CoreContext;+ use crate::core::runtime::DispatchCtx;++ let mut voice_off = ComponentSet::all();+ voice_off.voice = false;+ let off = DispatchCtx::new(CoreContext::for_test_with_components(voice_off));+ let on = DispatchCtx::new(CoreContext::for_test_with_components(ComponentSet::all()));++ // The two contexts answer independently, concurrently and across awaits.+ let ask = |ctx: DispatchCtx| async move {+ tokio::task::yield_now().await;+ lookup_capability(&ctx, "voice.ptt").expect("voice.ptt").value.status+ };+ let (disabled, enabled) = tokio::join!(ask(off), ask(on));+ assert_eq!(disabled, CapabilityStatus::Disabled);+ assert_ne!(enabled, CapabilityStatus::Disabled);+}diff --git a/crates/openhuman-core/src/threads/ops_title_and_cancellation_tests.rs b/crates/openhuman-core/src/threads/ops_title_and_cancellation_tests.rsindex 761c18c8b8..f0ca714187 100644--- a/crates/openhuman-core/src/threads/ops_title_and_cancellation_tests.rs+++ b/crates/openhuman-core/src/threads/ops_title_and_cancellation_tests.rs@@ -68,7 +68,8 @@ async fn run_to_completion_runs_the_tail_after_the_caller_is_dropped() {let flag = Arc::clone(&tail_ran);let (release, parked) = tokio::sync::oneshot::channel::<()>();- let mut call = Box::pin(run_to_completion("test_destructive_op", async move {+ let dispatch = crate::core::runtime::DispatchCtx::unbound();+ let mut call = Box::pin(run_to_completion(&dispatch, "test_destructive_op", async move {// Stands in for the blocking store mutation still in progress.let _ = parked.await;// Stands in for the cleanup that must never be skipped.@@ -101,3 +102,35 @@ async fn run_to_completion_runs_the_tail_after_the_caller_is_dropped() {.await.expect("cleanup must still run after the caller's future was dropped");}++/// The detached task runs under the context the caller handed over, not the+/// one its own task happens to be scoped to, and two callers for different+/// contexts do not see each other's.+#[tokio::test]+async fn run_to_completion_runs_under_the_explicit_context() {+ use crate::core::runtime::context::CoreContext;+ use crate::core::runtime::{DispatchCtx, DomainSet};+ use std::sync::Arc;++ let a = CoreContext::for_test(DomainSet::full(), Some(std::path::PathBuf::from("/tmp/a")));+ let b = CoreContext::for_test(DomainSet::full(), Some(std::path::PathBuf::from("/tmp/b")));+ let seen_by = |dispatch: DispatchCtx| async move {+ run_to_completion(&dispatch, "test_context", async {+ tokio::task::yield_now().await;+ Ok::<_, String>(CoreContext::current())+ })+ .await+ .expect("task joins")+ .expect("the task has a context")+ };+ // `b` is the caller's own scope; `a` is handed over explicitly and wins.+ let (seen_a, seen_b) = CoreContext::scope(Arc::clone(&b), async {+ tokio::join!(+ seen_by(DispatchCtx::new(Arc::clone(&a))),+ seen_by(DispatchCtx::new(Arc::clone(&b)))+ )+ })+ .await;+ assert!(Arc::ptr_eq(&seen_a, &a));+ assert!(Arc::ptr_eq(&seen_b, &b));+}