Skip to content

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

test(profile): cover the embed-fleet agent ids and per-agent math (#7032)

oxoxDev04f07fe5d9ca
diff --git a/crates/openhuman-cli/src/bin/library_profile/scenarios/embed_fleet.rs b/crates/openhuman-cli/src/bin/library_profile/scenarios/embed_fleet.rs
index b698078910..779836cef8 100644
--- a/crates/openhuman-cli/src/bin/library_profile/scenarios/embed_fleet.rs
+++ b/crates/openhuman-cli/src/bin/library_profile/scenarios/embed_fleet.rs
@@ -224,3 +224,7 @@ pub async fn run() -> Result<ProfileResult> {
drop(runtime);
Ok(result)
}
+
+#[cfg(test)]
+#[path = "embed_fleet_tests.rs"]
+mod tests;
diff --git a/crates/openhuman-cli/src/bin/library_profile/scenarios/embed_fleet_tests.rs b/crates/openhuman-cli/src/bin/library_profile/scenarios/embed_fleet_tests.rs
new file mode 100644
index 0000000000..4bc468e09a
--- /dev/null
+++ b/crates/openhuman-cli/src/bin/library_profile/scenarios/embed_fleet_tests.rs
@@ -0,0 +1,17 @@
+use super::*;
+
+#[test]
+fn agent_ids_are_distinct_and_valid() {
+ let ids: std::collections::HashSet<String> = (0..500).map(agent_id).collect();
+ assert_eq!(ids.len(), 500);
+ assert!(ids.iter().all(|id| id
+ .bytes()
+ .all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'-')));
+}
+
+#[test]
+fn per_agent_divides_the_delta_and_skips_an_empty_fleet() {
+ assert_eq!(per_agent(1_000, 3_000, 4), Some(500.0));
+ assert_eq!(per_agent(3_000, 1_000, 4), Some(-500.0));
+ assert_eq!(per_agent(1_000, 3_000, 0), None);
+}