Skip to content

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

fix(test): make test helpers async to avoid blocking in async context

Steven Enamakel8eff543871b1
diff --git a/crates/openhuman-core/src/agent/artifacts/ops_tests.rs b/crates/openhuman-core/src/agent/artifacts/ops_tests.rs
index 451998805d..a39ac7110a 100644
--- a/crates/openhuman-core/src/agent/artifacts/ops_tests.rs
+++ b/crates/openhuman-core/src/agent/artifacts/ops_tests.rs
@@ -319,7 +319,7 @@ struct DefaultFilesDir {
}
impl DefaultFilesDir {
- fn under(tmp: &TempDir) -> Self {
+ async fn under(tmp: &TempDir) -> Self {
let lock = crate::config::TEST_ENV_LOCK
.blocking_lock();
let previous = std::env::var_os("OPENHUMAN_PROJECTS_DIR");
@@ -352,7 +352,7 @@ async fn get_returns_the_files_folder_path() {
use crate::agent::artifacts::types::ArtifactKind;
let tmp = TempDir::new().unwrap();
let config = test_config(&tmp);
- let default = DefaultFilesDir::under(&tmp);
+ let default = DefaultFilesDir::under(&tmp).await;
let files_dir = default.files_dir.clone();
let (meta, path) = create_artifact(
tmp.path(),
@@ -384,7 +384,7 @@ async fn get_reports_a_ready_file_removed_outside_openhuman() {
use crate::agent::artifacts::types::ArtifactKind;
let tmp = TempDir::new().unwrap();
let config = test_config(&tmp);
- let default = DefaultFilesDir::under(&tmp);
+ let default = DefaultFilesDir::under(&tmp).await;
let (meta, path) = create_artifact(
tmp.path(),
&default.files_dir,
@@ -410,7 +410,7 @@ async fn get_and_delete_refuse_a_record_rooted_outside_the_files_folder() {
use crate::agent::artifacts::types::{ArtifactKind, ArtifactMeta, ArtifactStatus};
let tmp = TempDir::new().unwrap();
let config = test_config(&tmp);
- let _default = DefaultFilesDir::under(&tmp);
+ let _default = DefaultFilesDir::under(&tmp).await;
let home = tmp.path().join("home");
let private = home.join("private.pdf");
std::fs::create_dir_all(&home).unwrap();
diff --git a/crates/openhuman-core/src/security/approval/gate_tests.rs b/crates/openhuman-core/src/security/approval/gate_tests.rs
index 7e4b06660c..a0a34a4576 100644
--- a/crates/openhuman-core/src/security/approval/gate_tests.rs
+++ b/crates/openhuman-core/src/security/approval/gate_tests.rs
@@ -78,7 +78,7 @@ fn parked_request_id(gate: &ApprovalGate) -> Option<String> {
/// these tests unnecessarily.
/// `test_gate_with_ttl` must not take the lock, because the
/// `effective_ttl_*` tests call it while already holding it.
-fn expiry_gate() -> (ApprovalGate, TempDir, EnvVarGuard) {
+async fn expiry_gate() -> (ApprovalGate, TempDir, EnvVarGuard) {
// The lock keeps a sibling test from setting the override, but not a
// developer who exported it in their shell. effective_ttl would then
// replace EXPIRY_TEST_TTL at park time and the wait would be measuring
diff --git a/crates/openhuman-core/src/threads/ops/live_state_tests.rs b/crates/openhuman-core/src/threads/ops/live_state_tests.rs
index 7abd0c26f7..c19805291b 100644
--- a/crates/openhuman-core/src/threads/ops/live_state_tests.rs
+++ b/crates/openhuman-core/src/threads/ops/live_state_tests.rs
@@ -23,7 +23,7 @@ struct WorkspaceGuard {
}
impl WorkspaceGuard {
- fn new() -> Self {
+ async fn new() -> Self {
let lock = TEST_ENV_LOCK.blocking_lock();
let tmp = tempfile::tempdir().expect("tempdir");
unsafe {
@@ -49,7 +49,7 @@ impl Drop for WorkspaceGuard {
/// one is set.
#[tokio::test]
async fn goal_get_reads_back_a_stored_goal() {
- let _ws = WorkspaceGuard::new();
+ let _ws = WorkspaceGuard::new().await;
let empty = goal_get(ThreadLiveStateRequest {
thread_id: "thread-goal-live".to_string(),
@@ -82,7 +82,7 @@ async fn goal_get_reads_back_a_stored_goal() {
/// wrote for the same thread.
#[tokio::test]
async fn todos_get_reads_back_what_the_todo_tool_wrote() {
- let _ws = WorkspaceGuard::new();
+ let _ws = WorkspaceGuard::new().await;
let dir = crate::config::Config::load_or_init()
.await
.unwrap()