Skip to content

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

test(storage_schema): add schema preparation test

Steven Enamakele72bfb491b9c
diff --git a/crates/openhuman-core/src/threads/store/storage_schema_tests.rs b/crates/openhuman-core/src/threads/store/storage_schema_tests.rs
index 09132d01e8..3ed5b57277 100644
--- a/crates/openhuman-core/src/threads/store/storage_schema_tests.rs
+++ b/crates/openhuman-core/src/threads/store/storage_schema_tests.rs
@@ -1,7 +1,7 @@
use super::*;
use serde_json::{json, Value};
use tinystoragedrivers::schema::ScopeClass;
-use tinystoragedrivers::Meta;
+use tinystoragedrivers::{Meta, Precondition, StorageBackend};
#[test]
fn a_recorded_key_moves_under_the_threads_owner_keeping_its_body() {
@@ -34,6 +34,39 @@ fn channel_attachment_and_viseme_records_are_declared_in_the_threads_owner() {
}
}
+#[tokio::test]
+async fn schema_prepares_the_scoped_projection_and_media_collections() {
+ use crate::storage::{MemoryStorage, scope_for_profile};
+
+ let registry =
+ tinystoragedrivers::schema::Registry::compose([storage_schema()]).unwrap();
+ let backend = MemoryStorage::new();
+ registry.prepare(&backend).await.unwrap();
+
+ let tenant_scope = scope_for_profile("schema-test");
+ let tenant = backend.for_scope(&tenant_scope).unwrap();
+ tenant
+ .documents()
+ .put(
+ CHANNEL_MESSAGES,
+ "provider-message",
+ json!({ "threadId": "thread-1" }),
+ Precondition::Absent,
+ )
+ .await
+ .unwrap();
+
+ let agent_scope = tenant_scope.agent("assistant").unwrap();
+ let agent = backend.for_scope(&agent_scope).unwrap();
+ for collection in [STAGED_ATTACHMENTS, REPLY_VISEME_TIMELINES] {
+ agent
+ .documents()
+ .put(collection, "record-1", json!({}), Precondition::Absent)
+ .await
+ .unwrap();
+ }
+}
+
#[test]
fn the_schema_composes_under_its_owner() {
tinystoragedrivers::schema::Registry::compose([storage_schema()]).unwrap();