Skip to content

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

feat(memory): add composio source tests

Steven Enamakel92d7c8552c8d
diff --git a/crates/openhuman-core/src/memory/engine.rs b/crates/openhuman-core/src/memory/engine.rs
index 716c082b0b..f2eb1a54ef 100644
--- a/crates/openhuman-core/src/memory/engine.rs
+++ b/crates/openhuman-core/src/memory/engine.rs
@@ -122,6 +122,16 @@ pub(crate) fn install_test_engine(workspace: &std::path::Path, engine: Arc<dyn M
.insert(workspace.to_path_buf(), engine);
}
+/// Unbinds the test engine of `workspace`, so memory there is off again
+/// (tests only).
+#[cfg(test)]
+pub(crate) fn remove_test_engine(workspace: &std::path::Path) {
+ TEST_ENGINES
+ .write()
+ .unwrap_or_else(std::sync::PoisonError::into_inner)
+ .remove(workspace);
+}
+
/// Test engines for one layout of a workspace (`None` legacy, `Some(root)`
/// v3), read by [`bind_with_root`] ahead of everything else, so a test can
/// hold both layouts at once as the layout migration does.
diff --git a/crates/openhuman-core/src/memory/sources/composio_tests.rs b/crates/openhuman-core/src/memory/sources/composio_tests.rs
index 1909481dd1..6c8ba670a9 100644
--- a/crates/openhuman-core/src/memory/sources/composio_tests.rs
+++ b/crates/openhuman-core/src/memory/sources/composio_tests.rs
@@ -626,15 +626,28 @@ async fn a_disconnect_while_signed_out_is_finished_on_the_next_sign_in() {
// Synced while signed in.
let engine = bind_reference(&config);
store_for(&config, "conn-s", "1").await;
- // Signed out: memory off, as a fresh workspace without an engine.
- let off = config_in(&tempfile::tempdir().unwrap());
- let mut signed_out = config.clone();
- signed_out.workspace_dir = config.workspace_dir.clone();
- let _ = off;
- crate::memory::engine::install_test_engine(
- &tmp.path().join("unused"),
- std::sync::Arc::new(tinymemory_api::conformance::ReferenceEngine::new()),
+
+ // Signed out (memory off), then disconnected: nothing reaches the cloud
+ // yet, and the deletion is queued rather than dropped.
+ crate::memory::engine::remove_test_engine(&config.workspace_dir);
+ assert_eq!(
+ forget_connection(&config, "conn-s", Some("gmail"))
+ .await
+ .unwrap(),
+ 0
);
- let _ = signed_out;
- let _ = engine;
+ assert_eq!(
+ crate::memory::deletion::pending(&config.workspace_dir),
+ vec![crate::memory::deletion::PendingDeletion::Connection {
+ connection_id: "conn-s".into(),
+ toolkit: Some("gmail".into()),
+ }]
+ );
+ assert_eq!(stored(&engine, MetaFilter::default()).await.len(), 1);
+
+ // Signed back in: the drain finishes the delete.
+ crate::memory::engine::install_test_engine(&config.workspace_dir, engine.clone());
+ assert_eq!(crate::memory::deletion::drain(&config).await, 1);
+ assert!(stored(&engine, MetaFilter::default()).await.is_empty());
+ assert!(crate::memory::deletion::pending(&config.workspace_dir).is_empty());
}