Skip to content

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

test(profiles): add coverage for background, credentials, host, layout, and ops

Steven Enamakelcff61f786fe5
diff --git a/crates/openhuman-core/src/profiles/background_tests.rs b/crates/openhuman-core/src/profiles/background_tests.rs
index 5c234630af..c325590180 100644
--- a/crates/openhuman-core/src/profiles/background_tests.rs
+++ b/crates/openhuman-core/src/profiles/background_tests.rs
@@ -24,7 +24,7 @@ async fn nothing_to_do_does_nothing() {
let tmp = tempfile::tempdir().unwrap();
let host = host(&tmp, 3600);
assert_eq!(tick(&host).await, TickReport::default());
- let id = ProfileId::for_user(&format!("idle-{}", uuid::Uuid::new_v4())).unwrap();
+ let id = ProfileId::for_user(&format!("idle-{}", uuid::Uuid::new_v4()), crate::profiles::ProfileIdMode::Raw).unwrap();
host.provision(&id).unwrap();
assert_eq!(tick(&host).await, TickReport::default());
assert!(
@@ -37,8 +37,8 @@ async fn nothing_to_do_does_nothing() {
async fn only_agents_with_queued_memory_jobs_are_run() {
let tmp = tempfile::tempdir().unwrap();
let host = host(&tmp, 3600);
- let busy = ProfileId::for_user(&format!("busy-{}", uuid::Uuid::new_v4())).unwrap();
- let quiet = ProfileId::for_user(&format!("quiet-{}", uuid::Uuid::new_v4())).unwrap();
+ let busy = ProfileId::for_user(&format!("busy-{}", uuid::Uuid::new_v4()), crate::profiles::ProfileIdMode::Raw).unwrap();
+ let quiet = ProfileId::for_user(&format!("quiet-{}", uuid::Uuid::new_v4()), crate::profiles::ProfileIdMode::Raw).unwrap();
host.provision(&busy).unwrap();
host.provision(&quiet).unwrap();
@@ -60,7 +60,7 @@ async fn only_agents_with_queued_memory_jobs_are_run() {
async fn a_tick_sweeps_idle_agents() {
let tmp = tempfile::tempdir().unwrap();
let host = host(&tmp, 0);
- let id = ProfileId::for_user(&format!("sweep-{}", uuid::Uuid::new_v4())).unwrap();
+ let id = ProfileId::for_user(&format!("sweep-{}", uuid::Uuid::new_v4()), crate::profiles::ProfileIdMode::Raw).unwrap();
host.provision(&id).unwrap();
drop(host.open(&id).unwrap());
assert!(host.is_open(&id));
diff --git a/crates/openhuman-core/src/profiles/credentials_tests.rs b/crates/openhuman-core/src/profiles/credentials_tests.rs
index 5dad7e6857..9490304269 100644
--- a/crates/openhuman-core/src/profiles/credentials_tests.rs
+++ b/crates/openhuman-core/src/profiles/credentials_tests.rs
@@ -8,7 +8,7 @@ use crate::profiles::ProfileId;
/// Credential secrets live in the process keyring keyed by agent id, which
/// every test in this binary shares; each test therefore uses its own users.
fn agent(tmp: &tempfile::TempDir, user: &str) -> Config {
- let id = ProfileId::for_user(&format!("{user}-{}", uuid::Uuid::new_v4())).unwrap();
+ let id = ProfileId::for_user(&format!("{user}-{}", uuid::Uuid::new_v4()), crate::profiles::ProfileIdMode::Raw).unwrap();
let layout = ProfileLayout::new(tmp.path(), &id);
std::fs::create_dir_all(&layout.workspace_dir).unwrap();
profile_config(&layout, &id)
diff --git a/crates/openhuman-core/src/profiles/host_tests.rs b/crates/openhuman-core/src/profiles/host_tests.rs
index dce3a69750..d200841514 100644
--- a/crates/openhuman-core/src/profiles/host_tests.rs
+++ b/crates/openhuman-core/src/profiles/host_tests.rs
@@ -8,7 +8,7 @@ fn host(tmp: &tempfile::TempDir, max_open: usize, idle_secs: u64) -> ProfileHost
}
fn agent(name: &str) -> ProfileId {
- ProfileId::for_user(name).unwrap()
+ ProfileId::for_user(name, crate::profiles::ProfileIdMode::Raw).unwrap()
}
#[test]
diff --git a/crates/openhuman-core/src/profiles/layout_tests.rs b/crates/openhuman-core/src/profiles/layout_tests.rs
index 7c3fa16294..ecfeb6bab6 100644
--- a/crates/openhuman-core/src/profiles/layout_tests.rs
+++ b/crates/openhuman-core/src/profiles/layout_tests.rs
@@ -1,7 +1,7 @@
use super::*;
fn id() -> ProfileId {
- ProfileId::for_user("layout-user").unwrap()
+ ProfileId::for_user("layout-user", crate::profiles::ProfileIdMode::Raw).unwrap()
}
#[test]
@@ -62,7 +62,7 @@ fn the_policy_is_on_and_closed() {
#[test]
fn artifacts_land_in_the_agents_sandbox() {
- let id = ProfileId::for_user("alice").unwrap();
+ let id = ProfileId::for_user("alice", crate::profiles::ProfileIdMode::Raw).unwrap();
let layout = ProfileLayout::new(std::path::Path::new("/srv/oh"), &id);
let config = profile_config(&layout, &id);
assert!(config.files_dir().starts_with(&layout.sandbox_dir));
diff --git a/crates/openhuman-core/src/profiles/ops_tests.rs b/crates/openhuman-core/src/profiles/ops_tests.rs
index 7a8af9752e..58c8895f05 100644
--- a/crates/openhuman-core/src/profiles/ops_tests.rs
+++ b/crates/openhuman-core/src/profiles/ops_tests.rs
@@ -31,7 +31,7 @@ fn status_and_deprovision_take_agent_ids_only() {
assert!(status_on(&host, "[email protected]").is_err());
assert!(deprovision_on(&host, "../operator").is_err());
- let id = ProfileId::for_user("alice").unwrap();
+ let id = ProfileId::for_user("alice", crate::profiles::ProfileIdMode::Raw).unwrap();
assert!(status_on(&host, id.as_str())
.unwrap_err()
.contains("not provisioned"));
@@ -48,8 +48,8 @@ fn credentials_are_set_and_cleared_per_agent_and_never_echoed() {
// The keyring holding credential secrets is shared by every test here.
let alice_user = format!("alice-{}", uuid::Uuid::new_v4());
let bob_user = format!("bob-{}", uuid::Uuid::new_v4());
- let alice = ProfileId::for_user(&alice_user).unwrap();
- let bob = ProfileId::for_user(&bob_user).unwrap();
+ let alice = ProfileId::for_user(&alice_user, crate::profiles::ProfileIdMode::Raw).unwrap();
+ let bob = ProfileId::for_user(&bob_user, crate::profiles::ProfileIdMode::Raw).unwrap();
assert!(set_credential_on(
&host,
alice.as_str(),