Skip to content

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

test(channels): add workspace env guard for sender tests

Steven Enamakel0d629c23cf90
diff --git a/crates/openhuman-core/src/channels/bus/delivery_tests.rs b/crates/openhuman-core/src/channels/bus/delivery_tests.rs
index b047248e4f..0240e0ab1a 100644
--- a/crates/openhuman-core/src/channels/bus/delivery_tests.rs
+++ b/crates/openhuman-core/src/channels/bus/delivery_tests.rs
@@ -1,5 +1,24 @@
use super::*;
+struct WorkspaceEnvGuard(Option<std::ffi::OsString>);
+
+impl WorkspaceEnvGuard {
+ fn set(path: &std::path::Path) -> Self {
+ let previous = std::env::var_os("OPENHUMAN_WORKSPACE");
+ std::env::set_var("OPENHUMAN_WORKSPACE", path);
+ Self(previous)
+ }
+}
+
+impl Drop for WorkspaceEnvGuard {
+ fn drop(&mut self) {
+ match self.0.take() {
+ Some(path) => std::env::set_var("OPENHUMAN_WORKSPACE", path),
+ None => std::env::remove_var("OPENHUMAN_WORKSPACE"),
+ }
+ }
+}
+
#[test]
fn outbound_body_has_stable_idempotency_key() {
let body = json!({ "text": "hello" });
@@ -12,6 +31,11 @@ fn outbound_body_has_stable_idempotency_key() {
#[tokio::test]
async fn sender_methods_report_unavailable_without_a_hosted_session() {
+ let _env_lock = crate::config::TEST_ENV_LOCK
+ .lock()
+ .unwrap_or_else(|error| error.into_inner());
+ let workspace = tempfile::tempdir().expect("temporary workspace");
+ let _workspace_env = WorkspaceEnvGuard::set(workspace.path());
let sender = BackendProgressiveSender;
assert!(matches!(