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
refactor(test): replace `set_to_path` with `set` in test environment guards
Steven Enamakelda228c40d46b
diff --git a/crates/openhuman-core/src/security/credentials/ops_credential_tests.rs b/crates/openhuman-core/src/security/credentials/ops_credential_tests.rsindex b53af1ae2c..6716d0be0d 100644--- a/crates/openhuman-core/src/security/credentials/ops_credential_tests.rs+++ b/crates/openhuman-core/src/security/credentials/ops_credential_tests.rs@@ -119,7 +119,7 @@ async fn set_credential_installs_a_session_without_touching_the_backend() {.unwrap_or_else(|e| e.into_inner());let tmp = TempDir::new().unwrap();std::fs::create_dir_all(tmp.path().join("workspace")).unwrap();- let _home = EnvVarGuard::set_to_path("HOME", tmp.path());+ let _home = EnvVarGuard::set("HOME", tmp.path());let mut config = test_config(&tmp);// A backend that would reject everything: it must never be consulted.config.api_url = Some(spawn_auth_me_status(StatusCode::UNAUTHORIZED).await);@@ -169,7 +169,7 @@ async fn set_credential_derives_the_user_id_from_the_jwt_subject() {.unwrap_or_else(|e| e.into_inner());let tmp = TempDir::new().unwrap();std::fs::create_dir_all(tmp.path().join("workspace")).unwrap();- let _home = EnvVarGuard::set_to_path("HOME", tmp.path());+ let _home = EnvVarGuard::set("HOME", tmp.path());let config = test_config(&tmp);let token = jwt_with_payload(json!({"sub": "from-claims",@@ -196,7 +196,7 @@ async fn set_credential_with_the_same_token_and_user_is_a_cheap_refresh() {.unwrap_or_else(|e| e.into_inner());let tmp = TempDir::new().unwrap();std::fs::create_dir_all(tmp.path().join("workspace")).unwrap();- let _home = EnvVarGuard::set_to_path("HOME", tmp.path());+ let _home = EnvVarGuard::set("HOME", tmp.path());let config = test_config(&tmp);let token = jwt_with_payload(json!({"sub": "user-7",@@ -241,7 +241,7 @@ async fn set_credential_for_a_different_user_signs_the_previous_one_out_first().unwrap_or_else(|e| e.into_inner());let tmp = TempDir::new().unwrap();std::fs::create_dir_all(tmp.path().join("workspace")).unwrap();- let _home = EnvVarGuard::set_to_path("HOME", tmp.path());+ let _home = EnvVarGuard::set("HOME", tmp.path());let config = test_config(&tmp);let exp = (chrono::Utc::now() + chrono::Duration::hours(1)).timestamp();store_session(@@ -324,7 +324,7 @@ async fn clearing_the_session_preserves_a_coexisting_api_key() {.unwrap_or_else(|e| e.into_inner());let tmp = TempDir::new().unwrap();std::fs::create_dir_all(tmp.path().join("workspace")).unwrap();- let _home = EnvVarGuard::set_to_path("HOME", tmp.path());+ let _home = EnvVarGuard::set("HOME", tmp.path());let config = test_config(&tmp);// Install the session first: this activates the user-scoped directory.@@ -399,7 +399,7 @@ async fn clearing_the_session_preserves_the_active_key_over_a_stale_destination_.unwrap_or_else(|e| e.into_inner());let tmp = TempDir::new().unwrap();std::fs::create_dir_all(tmp.path().join("workspace")).unwrap();- let _home = EnvVarGuard::set_to_path("HOME", tmp.path());+ let _home = EnvVarGuard::set("HOME", tmp.path());// `test_config` also binds the memory diagnostics `store_session` below// needs; its own config_path is a plain tmp fixture unrelated to the real// pre-login layout, so it is not where the RPC dispatcher would actually@@ -477,7 +477,7 @@ async fn clearing_without_a_kind_removes_a_user_scoped_api_key_at_its_source() {.unwrap_or_else(|e| e.into_inner());let tmp = TempDir::new().unwrap();std::fs::create_dir_all(tmp.path().join("workspace")).unwrap();- let _home = EnvVarGuard::set_to_path("HOME", tmp.path());+ let _home = EnvVarGuard::set("HOME", tmp.path());let config = test_config(&tmp);let exp = chrono::Utc::now() + chrono::Duration::hours(1);@@ -531,7 +531,7 @@ async fn clear_credential_without_a_kind_removes_everything() {.unwrap_or_else(|e| e.into_inner());let tmp = TempDir::new().unwrap();std::fs::create_dir_all(tmp.path().join("workspace")).unwrap();- let _home = EnvVarGuard::set_to_path("HOME", tmp.path());+ let _home = EnvVarGuard::set("HOME", tmp.path());let config = test_config(&tmp);set_credential(&config,@@ -567,7 +567,7 @@ async fn store_session_local_token_rejects_missing_user_payload() {.unwrap_or_else(|e| e.into_inner());let tmp = TempDir::new().unwrap();std::fs::create_dir_all(tmp.path().join("workspace")).unwrap();- let _home = EnvVarGuard::set_to_path("HOME", tmp.path());+ let _home = EnvVarGuard::set("HOME", tmp.path());let config = test_config(&tmp);let local_token = "header.payload.local";let err = store_session(&config, local_token, None, None)@@ -590,7 +590,7 @@ async fn store_session_local_token_succeeds_without_network_and_forces_local_use.unwrap_or_else(|e| e.into_inner());let tmp = TempDir::new().unwrap();std::fs::create_dir_all(tmp.path().join("workspace")).unwrap();- let _home = EnvVarGuard::set_to_path("HOME", tmp.path());+ let _home = EnvVarGuard::set("HOME", tmp.path());let config = test_config(&tmp);let local_token = "header.payload.local";let user = serde_json::json!({diff --git a/crates/openhuman-core/src/security/credentials/ops_provider_oauth_tests.rs b/crates/openhuman-core/src/security/credentials/ops_provider_oauth_tests.rsindex b1c07ed4cd..adc9e32173 100644--- a/crates/openhuman-core/src/security/credentials/ops_provider_oauth_tests.rs+++ b/crates/openhuman-core/src/security/credentials/ops_provider_oauth_tests.rs@@ -14,7 +14,7 @@ async fn clear_session_on_empty_store_reports_removed_false() {.lock().unwrap_or_else(|e| e.into_inner());let tmp = TempDir::new().unwrap();- let _home = EnvVarGuard::set_to_path("HOME", tmp.path());+ let _home = EnvVarGuard::set("HOME", tmp.path());let config = test_config(&tmp);let result = clear_session(&config).await.unwrap();assert_eq!(result.value["removed"], false);@@ -375,7 +375,7 @@ async fn clear_session_on_one_account_does_not_affect_another() {.unwrap_or_else(|e| e.into_inner());let tmp_a = TempDir::new().unwrap();let tmp_b = TempDir::new().unwrap();- let _home = EnvVarGuard::set_to_path("HOME", tmp_a.path());+ let _home = EnvVarGuard::set("HOME", tmp_a.path());let config_a = test_config(&tmp_a);let config_b = test_config(&tmp_b);@@ -494,7 +494,7 @@ async fn start_login_gated_services_completes_with_all_services_disabled() {// back in so it actually drives the concurrent spawn/await path it guards.// Only presence is checked, so the value (a temp path) is irrelevant.let _run_services =- EnvVarGuard::set_to_path("OPENHUMAN_RUN_LOGIN_GATED_SERVICES_IN_TEST", tmp.path());+ EnvVarGuard::set("OPENHUMAN_RUN_LOGIN_GATED_SERVICES_IN_TEST", tmp.path());let mut config = Config::default();// Every service is disabled so each `start_if_enabled` is a no-op: the testdiff --git a/crates/openhuman-core/src/threads/ops_conversion_tests.rs b/crates/openhuman-core/src/threads/ops_conversion_tests.rsindex 3575005ab7..430d8fc89f 100644--- a/crates/openhuman-core/src/threads/ops_conversion_tests.rs+++ b/crates/openhuman-core/src/threads/ops_conversion_tests.rs@@ -184,7 +184,7 @@ async fn message_append_returns_typed_not_found_for_stale_thread() {.lock().unwrap_or_else(|e| e.into_inner());let workspace = tempfile::tempdir().expect("workspace");- let _workspace_guard = EnvVarGuard::set_to_path("OPENHUMAN_WORKSPACE", workspace.path());+ let _workspace_guard = EnvVarGuard::set("OPENHUMAN_WORKSPACE", workspace.path());let thread_id = "thread-missing";let err = message_append(AppendConversationMessageRequest {@@ -216,7 +216,7 @@ async fn generate_title_returns_typed_not_found_for_stale_thread() {.lock().unwrap_or_else(|e| e.into_inner());let workspace = tempfile::tempdir().expect("workspace");- let _workspace_guard = EnvVarGuard::set_to_path("OPENHUMAN_WORKSPACE", workspace.path());+ let _workspace_guard = EnvVarGuard::set("OPENHUMAN_WORKSPACE", workspace.path());let thread_id = "thread-missing";let err = thread_generate_title(GenerateConversationThreadTitleRequest {@@ -241,7 +241,7 @@ async fn generate_title_leaves_custom_title_unchanged() {.lock().unwrap_or_else(|e| e.into_inner());let workspace = tempfile::tempdir().expect("workspace");- let _workspace_guard = EnvVarGuard::set_to_path("OPENHUMAN_WORKSPACE", workspace.path());+ let _workspace_guard = EnvVarGuard::set("OPENHUMAN_WORKSPACE", workspace.path());let thread_id = "thread-custom";create_thread_with_title(&workspace, thread_id, "Already named").await;let dir = crate::config::Config::load_or_init()@@ -282,7 +282,7 @@ async fn generate_title_returns_existing_title_when_no_user_message_exists() {.lock().unwrap_or_else(|e| e.into_inner());let workspace = tempfile::tempdir().expect("workspace");- let _workspace_guard = EnvVarGuard::set_to_path("OPENHUMAN_WORKSPACE", workspace.path());+ let _workspace_guard = EnvVarGuard::set("OPENHUMAN_WORKSPACE", workspace.path());let thread_id = "thread-no-user";create_thread_with_title(&workspace, thread_id, "Chat Jan 1 1:00 AM").await;@@ -305,7 +305,7 @@ async fn generate_title_falls_back_to_first_user_message_when_assistant_missing(.lock().unwrap_or_else(|e| e.into_inner());let workspace = tempfile::tempdir().expect("workspace");- let _workspace_guard = EnvVarGuard::set_to_path("OPENHUMAN_WORKSPACE", workspace.path());+ let _workspace_guard = EnvVarGuard::set("OPENHUMAN_WORKSPACE", workspace.path());let thread_id = "thread-fallback";create_thread_with_title(&workspace, thread_id, "Chat Jan 1 1:00 AM").await;let dir = crate::config::Config::load_or_init()@@ -346,7 +346,7 @@ async fn thread_delete_removes_persisted_turn_state_snapshot() {.lock().unwrap_or_else(|e| e.into_inner());let workspace = tempfile::tempdir().expect("workspace");- let _workspace_guard = EnvVarGuard::set_to_path("OPENHUMAN_WORKSPACE", workspace.path());+ let _workspace_guard = EnvVarGuard::set("OPENHUMAN_WORKSPACE", workspace.path());let thread_id = "thread-delete";create_thread_with_title(&workspace, thread_id, "Chat Jan 1 1:00 AM").await;let dir = crate::config::Config::load_or_init()@@ -399,7 +399,7 @@ async fn threads_purge_removes_valid_and_corrupted_turn_state_files() {.lock().unwrap_or_else(|e| e.into_inner());let workspace = tempfile::tempdir().expect("workspace");- let _workspace_guard = EnvVarGuard::set_to_path("OPENHUMAN_WORKSPACE", workspace.path());+ let _workspace_guard = EnvVarGuard::set("OPENHUMAN_WORKSPACE", workspace.path());create_thread_with_title(&workspace, "thread-a", "Chat Jan 1 1:00 AM").await;create_thread_with_title(&workspace, "thread-b", "Chat Jan 1 1:01 AM").await;let dir = crate::config::Config::load_or_init()@@ -459,7 +459,7 @@ async fn turn_state_clear_reports_false_when_snapshot_is_absent() {.lock().unwrap_or_else(|e| e.into_inner());let workspace = tempfile::tempdir().expect("workspace");- let _workspace_guard = EnvVarGuard::set_to_path("OPENHUMAN_WORKSPACE", workspace.path());+ let _workspace_guard = EnvVarGuard::set("OPENHUMAN_WORKSPACE", workspace.path());let outcome = turn_state_clear(ClearTurnStateRequest {thread_id: "missing-thread".into(),@@ -478,7 +478,7 @@ async fn thread_update_title_rejects_empty_and_whitespace_only_titles() {.lock().unwrap_or_else(|e| e.into_inner());let workspace = tempfile::tempdir().expect("workspace");- let _workspace_guard = EnvVarGuard::set_to_path("OPENHUMAN_WORKSPACE", workspace.path());+ let _workspace_guard = EnvVarGuard::set("OPENHUMAN_WORKSPACE", workspace.path());for title in ["", " "] {let err = thread_update_title(crate::memory::UpdateConversationThreadTitleRequest {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 2a956181db..ddb1edd7b9 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@@ -6,7 +6,7 @@ async fn thread_update_title_persists_new_title() {.lock().unwrap_or_else(|e| e.into_inner());let workspace = tempfile::tempdir().expect("workspace");- let _workspace_guard = EnvVarGuard::set_to_path("OPENHUMAN_WORKSPACE", workspace.path());+ let _workspace_guard = EnvVarGuard::set("OPENHUMAN_WORKSPACE", workspace.path());let thread_id = "t-title";create_thread_with_title(&workspace, thread_id, "Original title").await;@@ -32,7 +32,7 @@ async fn thread_update_title_returns_error_for_missing_thread() {.lock().unwrap_or_else(|e| e.into_inner());let workspace = tempfile::tempdir().expect("workspace");- let _workspace_guard = EnvVarGuard::set_to_path("OPENHUMAN_WORKSPACE", workspace.path());+ let _workspace_guard = EnvVarGuard::set("OPENHUMAN_WORKSPACE", workspace.path());let err = thread_update_title(crate::memory::UpdateConversationThreadTitleRequest {thread_id: "nonexistent-thread".to_string(),