Skip to content

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

test(tools): cover media files roots being set before source builds

Steven Enamakel77a1e13ba8c8
diff --git a/crates/openhuman-core/src/tools/sources_tests.rs b/crates/openhuman-core/src/tools/sources_tests.rs
index 8f00d68ea5..b75f1f827f 100644
--- a/crates/openhuman-core/src/tools/sources_tests.rs
+++ b/crates/openhuman-core/src/tools/sources_tests.rs
@@ -182,3 +182,24 @@ fn anchored_sources_sit_where_the_catalogue_always_listed_them() {
// Sibling tests register sources on the same process-wide slot, so only
// relative positions are asserted, never the total length.
}
+
+/// A media source that reads the security policy's files roots while it builds
+/// must find them already recorded.
+#[cfg(feature = "media")]
+#[test]
+fn media_files_roots_are_recorded_before_any_source_builds() {
+ let tmp = TempDir::new().unwrap();
+ let seen = Arc::new(std::sync::Mutex::new(None));
+ let sink = Arc::clone(&seen);
+ register_tool_source_at(
+ "test::roots",
+ ANCHOR_AFTER_SEARCH,
+ move |ctx| {
+ *sink.lock().unwrap() = Some(ctx.security.media_files_roots.lock().unwrap().is_some());
+ Vec::new()
+ },
+ );
+ let _ = assemble(&tmp);
+ unregister_tool_source("test::roots");
+ assert_eq!(*seen.lock().unwrap(), Some(true));
+}