The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(notifications): cover core notifications after workspace move
Steven Enamakel7bffc98a8de6
diff --git a/crates/openhuman-core/src/desktop/notifications/store.rs b/crates/openhuman-core/src/desktop/notifications/store.rsindex af03cd365d..b0c1f91d02 100644--- a/crates/openhuman-core/src/desktop/notifications/store.rs+++ b/crates/openhuman-core/src/desktop/notifications/store.rs@@ -189,11 +189,7 @@ pub fn list_core_notifications(limit: usize,) -> Result<Vec<CoreNotificationEvent>> {if let Some(docs) = super::store_documents::current(config)? {- return docs.list_core_notifications(- docs.workspace(),- only_unread,- limit,- );+ return docs.list_core_notifications(docs.workspace(), only_unread, limit);}with_connection(config, |conn| {let sql = if only_unread {diff --git a/crates/openhuman-core/src/desktop/notifications/store_documents.rs b/crates/openhuman-core/src/desktop/notifications/store_documents.rsindex 5d529c9659..419459003d 100644--- a/crates/openhuman-core/src/desktop/notifications/store_documents.rs+++ b/crates/openhuman-core/src/desktop/notifications/store_documents.rs@@ -90,8 +90,10 @@ pub(super) fn current(config: &Config) -> Result<Option<Docs>> {read: &|| super::store::import::read(config),};let db_path = super::store::db_path(config);- Ok(local::repo(config, &db_path, DOMAIN, collections, &plan)?- .map(|repo| Docs(repo, workspace)))+ Ok(+ local::repo(config, &db_path, DOMAIN, collections, &plan)?+ .map(|repo| Docs(repo, workspace)),+ )}fn status_of(raw: Option<&str>) -> NotificationStatus {diff --git a/crates/openhuman-core/src/desktop/notifications/store_import.rs b/crates/openhuman-core/src/desktop/notifications/store_import.rsindex 001c2ae0b2..0b8db94eae 100644--- a/crates/openhuman-core/src/desktop/notifications/store_import.rs+++ b/crates/openhuman-core/src/desktop/notifications/store_import.rs@@ -19,7 +19,9 @@ use anyhow::{Context, Result};use rusqlite::Connection;use serde_json::json;-use super::super::store_documents::{core_id, to_doc, CORE, LOCAL_WORKSPACE, NOTIFICATIONS, SETTINGS};+use super::super::store_documents::{+ core_id, to_doc, CORE, LOCAL_WORKSPACE, NOTIFICATIONS, SETTINGS,+};use crate::config::Config;use crate::storage::local::{table_exists, ImportDoc};diff --git a/crates/openhuman-core/src/desktop/notifications/store_import_tests.rs b/crates/openhuman-core/src/desktop/notifications/store_import_tests.rsindex a2a72a65d3..dabf165247 100644--- a/crates/openhuman-core/src/desktop/notifications/store_import_tests.rs+++ b/crates/openhuman-core/src/desktop/notifications/store_import_tests.rs@@ -113,3 +113,31 @@ fn legacy_notifications_are_imported_once_through_the_public_api() {assert_eq!(old.status, NotificationStatus::Dismissed);assert_eq!(after.len(), 3);}++#[test]+fn core_notifications_survive_a_moved_workspace() {+ let (dir, classic, default) = workspace();+ live::insert_core_notification(&classic, &event("e1", 1_000)).unwrap();+ // Imported, then one more written through the default store.+ assert_eq!(live::unread_core_notification_count(&default).unwrap(), 1);+ live::insert_core_notification(&default, &event("e2", 2_000)).unwrap();+ let db = live::db_path(&default);+ forget(&db);++ // The workspace is moved; its database comes along.+ let moved_root = TempDir::new().unwrap();+ let moved_dir = moved_root.path().join("moved");+ std::fs::rename(dir.path(), &moved_dir).unwrap();+ let moved = Config {+ workspace_dir: moved_dir.clone(),+ ..Config::default()+ };+ let core = live::list_core_notifications(&moved, false, 10).unwrap();+ let ids: Vec<_> = core.iter().map(|e| e.id.as_str()).collect();+ assert_eq!(ids, ["e2", "e1"]);+ assert!(live::mark_core_notification_read(&moved, "e1").unwrap());+ assert_eq!(live::unread_core_notification_count(&moved).unwrap(), 1);+ forget(&live::db_path(&moved));+ // Put it back so the TempDir cleans up.+ std::fs::rename(&moved_dir, dir.path()).unwrap();+}