Skip to content

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

test(memory): cover pending deletion subscriber and drain paths

Steven Enamakelc5e425aa0dd5
diff --git a/crates/openhuman-core/src/memory/bus_tests.rs b/crates/openhuman-core/src/memory/bus_tests.rs
index 55968f9d16..9a66de2cae 100644
--- a/crates/openhuman-core/src/memory/bus_tests.rs
+++ b/crates/openhuman-core/src/memory/bus_tests.rs
@@ -36,3 +36,44 @@ async fn the_background_job_runs_the_due_queue() {
run_system_job(&config, "someone_elses_job").await;
run_system_job(&config, SOURCES_SYNC_JOB).await;
}
+
+#[test]
+fn the_deletions_subscriber_listens_on_auth() {
+ let subscriber = PendingDeletionsSubscriber;
+ assert_eq!(subscriber.name(), "memory::pending_deletions");
+ assert_eq!(subscriber.domains(), Some(&["auth"][..]));
+}
+
+#[tokio::test]
+async fn a_sign_in_drains_the_deletions_queued_while_signed_out() {
+ use crate::memory::deletion::{enqueue, pending, PendingDeletion};
+
+ let tmp = tempfile::tempdir().unwrap();
+ let config = config_in(&tmp);
+ enqueue(
+ &config.workspace_dir,
+ PendingDeletion::Thread {
+ thread_id: "t".into(),
+ },
+ );
+ bind_reference(&config);
+ assert_eq!(drain_pending_deletions(&config, "session").await, 1);
+ assert!(pending(&config.workspace_dir).is_empty());
+}
+
+#[tokio::test]
+async fn the_background_job_retries_pending_deletions() {
+ use crate::memory::deletion::{enqueue, pending, PendingDeletion};
+
+ let tmp = tempfile::tempdir().unwrap();
+ let config = config_in(&tmp);
+ enqueue(
+ &config.workspace_dir,
+ PendingDeletion::Thread {
+ thread_id: "t".into(),
+ },
+ );
+ bind_reference(&config);
+ run_system_job(&config, BACKGROUND_JOB).await;
+ assert!(pending(&config.workspace_dir).is_empty());
+}