Skip to content

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

refactor(keyring): extract workspace resolution into a testable function

Steven Enamakel34688729eac3
diff --git a/src/openhuman/security/keyring/store.rs b/src/openhuman/security/keyring/store.rs
index 6c20a0ff1c..52f4f67f39 100644
--- a/src/openhuman/security/keyring/store.rs
+++ b/src/openhuman/security/keyring/store.rs
@@ -214,7 +214,11 @@ pub fn workspace_dir_for_file_backend() -> PathBuf {
/// The production resolution rule, kept compiled in test builds so it stays
/// directly testable (see `store_tests.rs`).
fn resolve_workspace_dir_from_process_state() -> PathBuf {
- if let Some(dir) = WORKSPACE_DIR.get() {
+ resolve_workspace_dir(WORKSPACE_DIR.get())
+}
+
+fn resolve_workspace_dir(registered_workspace: Option<&PathBuf>) -> PathBuf {
+ if let Some(dir) = registered_workspace {
return dir.clone();
}
diff --git a/src/openhuman/security/keyring/store_tests.rs b/src/openhuman/security/keyring/store_tests.rs
index 431ef7a6cd..9bd8c123ee 100644
--- a/src/openhuman/security/keyring/store_tests.rs
+++ b/src/openhuman/security/keyring/store_tests.rs
@@ -18,7 +18,7 @@
use std::path::PathBuf;
use super::test_scope::ScopedWorkspace;
-use super::{resolve_workspace_dir_from_process_state, workspace_dir_for_file_backend};
+use super::{resolve_workspace_dir, workspace_dir_for_file_backend};
use crate::openhuman::config::TEST_ENV_LOCK;
use crate::openhuman::security::keyring;
@@ -73,7 +73,7 @@ fn production_resolution_still_honours_the_workspace_env_var() {
let _guard = EnvVarGuard::set("OPENHUMAN_WORKSPACE", tmp.path());
assert_eq!(
- resolve_workspace_dir_from_process_state(),
+ resolve_workspace_dir(None),
tmp.path().to_path_buf()
);
}