Skip to content

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

test(storage): prove storage::open connects on the storage runtime

oxoxDev761dc25e0d46
diff --git a/crates/openhuman-core/src/storage/mod_tests.rs b/crates/openhuman-core/src/storage/mod_tests.rs
index 24c8d3c749..f83fd952f3 100644
--- a/crates/openhuman-core/src/storage/mod_tests.rs
+++ b/crates/openhuman-core/src/storage/mod_tests.rs
@@ -318,6 +318,47 @@ mod storage_runtime {
assert!(result.is_err(), "a panic surfaces as a StorageError");
}
+ #[derive(Clone, Default)]
+ struct Captured(std::sync::Arc<std::sync::Mutex<Vec<u8>>>);
+
+ impl std::io::Write for Captured {
+ fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
+ self.0.lock().unwrap().extend_from_slice(buf);
+ Ok(buf.len())
+ }
+
+ fn flush(&mut self) -> std::io::Result<()> {
+ Ok(())
+ }
+ }
+
+ impl<'a> tracing_subscriber::fmt::MakeWriter<'a> for Captured {
+ type Writer = Captured;
+
+ fn make_writer(&'a self) -> Self::Writer {
+ self.clone()
+ }
+ }
+
+ #[tokio::test]
+ async fn open_connects_on_the_storage_runtime() {
+ let captured = Captured::default();
+ let subscriber = tracing_subscriber::fmt()
+ .with_writer(captured.clone())
+ .with_max_level(tracing::Level::DEBUG)
+ .with_ansi(false)
+ .finish();
+ let guard = tracing::subscriber::set_default(subscriber);
+ let backend = super::super::open("memory").await;
+ drop(guard);
+ assert!(backend.is_ok(), "memory backend opens");
+ let log = String::from_utf8(captured.0.lock().unwrap().clone()).unwrap();
+ assert!(
+ log.contains("connecting on the storage runtime"),
+ "open must connect through the storage runtime, got: {log}"
+ );
+ }
+
#[test]
fn bridged_calls_do_not_starve_a_capped_host_runtime() {
let (done, outcome) = std_mpsc::channel();