Skip to content

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

refactor(tests): update key creation in storage tests

Steven Enamakele24fb3f9122f
diff --git a/crates/openhuman-core/src/profiles/storage_schema_tests.rs b/crates/openhuman-core/src/profiles/storage_schema_tests.rs
index 131d9619fe..6ceb7a79a6 100644
--- a/crates/openhuman-core/src/profiles/storage_schema_tests.rs
+++ b/crates/openhuman-core/src/profiles/storage_schema_tests.rs
@@ -85,7 +85,7 @@ async fn migrate_cluster_moves_v1_leases_into_tsd_leases_and_keeps_their_epoch()
migrate_cluster(&scoped).await.unwrap();
assert!(docs.get("leases", "alice").await.unwrap().is_none());
assert!(docs.get("leases", "bob").await.unwrap().is_none());
- let id = tinystoragedrivers::Key::of([LEASE_OWNER, "alice"]).unwrap();
+ let id = crate::storage::schema_support::key_of_parts([LEASE_OWNER, "alice"]).unwrap();
let moved = docs.get("tsd.leases", id.as_str()).await.unwrap().unwrap();
assert_eq!(
moved.doc,
diff --git a/crates/openhuman-core/src/storage/schema_support_tests.rs b/crates/openhuman-core/src/storage/schema_support_tests.rs
index 12b3977d38..beed7ef59c 100644
--- a/crates/openhuman-core/src/storage/schema_support_tests.rs
+++ b/crates/openhuman-core/src/storage/schema_support_tests.rs
@@ -28,6 +28,19 @@ fn a_natural_key_escapes_separators() {
assert!(key_of("").is_err());
}
+#[test]
+fn composite_keys_round_trip_reserved_and_unicode_parts() {
+ let encoded = key_of_parts(["a/b", "c%~é"]).unwrap();
+ assert_eq!(encoded, "a%2Fb/c%25%7Eé");
+ assert_eq!(Key::new(encoded).unwrap().split().unwrap(), ["a/b", "c%~é"]);
+ assert!(key_of_parts(["a", ""]).is_err());
+}
+
+#[test]
+fn fresh_record_key_is_accepted_by_the_storage_key_type() {
+ assert!(Key::new(fresh_key()).is_ok());
+}
+
#[test]
fn keys_convert_at_every_depth_and_back() {
let renames = [("createdAtMillis", "created_ms")];