Skip to content

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

test(modules): move registry contract tests into their own file

Steven Enamakeldf50e3187eb6
diff --git a/crates/openhuman-core/src/modules/registry.rs b/crates/openhuman-core/src/modules/registry.rs
index 7c5daab35d..af2ab2b848 100644
--- a/crates/openhuman-core/src/modules/registry.rs
+++ b/crates/openhuman-core/src/modules/registry.rs
@@ -34,6 +34,10 @@
#[path = "registry_tests.rs"]
mod tests;
+#[cfg(all(test, feature = "modules"))]
+#[path = "registry_contract_tests.rs"]
+mod contract_tests;
+
mod records_computer;
mod records_docs_wallet;
mod records_extra;
diff --git a/crates/openhuman-core/src/modules/registry_contract_tests.rs b/crates/openhuman-core/src/modules/registry_contract_tests.rs
new file mode 100644
index 0000000000..0ac0e36809
--- /dev/null
+++ b/crates/openhuman-core/src/modules/registry_contract_tests.rs
@@ -0,0 +1,124 @@
+//! Registry metadata against each module's bus contract constants.
+
+use super::{find, ALL};
+
+/// The interface and object path each contract crate publishes, keyed by the
+/// module id the registry uses. This is written out from the contract
+/// constants, not from the records, so a record that drifts from its contract
+/// (or a contract that is renamed upstream) fails here rather than at the first
+/// bus call. Records behind an optional contract crate are listed under the
+/// same gate as the crate.
+fn contract_names() -> Vec<(&'static str, &'static str, &'static str)> {
+ #[allow(unused_mut)]
+ let mut names = vec![
+ (
+ "tinycomputer",
+ tinycomputer_bus::names::INTERFACE,
+ tinycomputer_bus::names::OBJECT_PATH,
+ ),
+ (
+ "tinysearch",
+ tinysearch_bus::names::INTERFACE,
+ tinysearch_bus::names::OBJECT_PATH,
+ ),
+ (
+ "tinyjuice",
+ tinyjuice_bus::names::BUS_NAME,
+ tinyjuice_bus::names::OBJECT_PATH,
+ ),
+ (
+ "tinymcp",
+ tinymcp_bus::names::INTERFACE,
+ tinymcp_bus::names::OBJECT_PATH,
+ ),
+ (
+ "tinyconnectors",
+ tinyconnectors_bus::names::INTERFACE,
+ tinyconnectors_bus::names::OBJECT_PATH,
+ ),
+ (
+ "tinychannels",
+ tinychannels_bus::names::BUS_NAME,
+ tinychannels_bus::names::OBJECT_PATH,
+ ),
+ ];
+ #[cfg(feature = "modules")]
+ names.push(("tinybox", tinybox_bus::INTERFACE, tinybox_bus::OBJECT_PATH));
+ #[cfg(feature = "documents")]
+ names.push((
+ "tinydocs",
+ tinydocs_bus::names::BUS_NAME,
+ tinydocs_bus::names::OBJECT_PATH,
+ ));
+ #[cfg(feature = "web3")]
+ names.push((
+ "tinywallet",
+ tinywallet_bus::names::BUS_NAME,
+ tinywallet_bus::names::OBJECT_PATH,
+ ));
+ #[cfg(feature = "voice")]
+ names.push((
+ "tinyvoice",
+ tinyvoice_bus::names::BUS_NAME,
+ tinyvoice_bus::names::OBJECT_PATH,
+ ));
+ #[cfg(feature = "hosting")]
+ names.push((
+ "tinyhosts",
+ tinyhosts_bus::BUS_NAME,
+ tinyhosts_bus::OBJECT_PATH,
+ ));
+ names
+}
+
+#[test]
+fn every_record_matches_its_contract_constants() {
+ let contracts = contract_names();
+ assert_eq!(contracts.len(), ALL.len(), "a record has no contract entry");
+ for (id, bus_name, object_path) in contracts {
+ let record = find(id).unwrap_or_else(|| panic!("{id} has no registry record"));
+ assert_eq!(
+ record.bus_name, bus_name,
+ "{id} bus name drifted from its contract"
+ );
+ assert_eq!(
+ record.object_path, object_path,
+ "{id} object path drifted from its contract"
+ );
+ }
+}
+
+#[test]
+fn a_drifted_contract_constant_is_reported_as_a_mismatch() {
+ // The comparison must be able to fail: a fixture whose constant differs
+ // from the record (as a renamed upstream interface would) is not equal.
+ let record = find("tinymcp").unwrap();
+ let drifted = format!("{}Renamed", tinymcp_bus::names::INTERFACE);
+ assert_ne!(record.bus_name, drifted);
+}
+
+#[cfg(all(
+ feature = "documents",
+ feature = "web3",
+ feature = "voice",
+ feature = "hosting"
+))]
+#[test]
+fn a_product_feature_build_carries_all_eleven_records() {
+ assert_eq!(ALL.len(), 11);
+ for id in [
+ "tinycomputer",
+ "tinysearch",
+ "tinydocs",
+ "tinywallet",
+ "tinyjuice",
+ "tinyvoice",
+ "tinymcp",
+ "tinyconnectors",
+ "tinybox",
+ "tinychannels",
+ "tinyhosts",
+ ] {
+ assert!(find(id).is_some(), "{id} missing from the registry");
+ }
+}
diff --git a/crates/openhuman-core/src/modules/registry_tests.rs b/crates/openhuman-core/src/modules/registry_tests.rs
index 8b497dc66a..fda893607c 100644
--- a/crates/openhuman-core/src/modules/registry_tests.rs
+++ b/crates/openhuman-core/src/modules/registry_tests.rs
@@ -722,124 +722,3 @@ fn source_artifact_file_names_follow_the_platform_convention() {
}
}
}
-
-/// The interface and object path each contract crate publishes, keyed by the
-/// module id the registry uses. This is written out from the contract
-/// constants, not from the records, so a record that drifts from its contract
-/// (or a contract that is renamed upstream) fails here rather than at the first
-/// bus call. Records behind an optional contract crate are listed under the
-/// same gate as the crate.
-fn contract_names() -> Vec<(&'static str, &'static str, &'static str)> {
- #[allow(unused_mut)]
- let mut names = vec![
- (
- "tinycomputer",
- tinycomputer_bus::names::INTERFACE,
- tinycomputer_bus::names::OBJECT_PATH,
- ),
- (
- "tinysearch",
- tinysearch_bus::names::INTERFACE,
- tinysearch_bus::names::OBJECT_PATH,
- ),
- (
- "tinyjuice",
- tinyjuice_bus::names::BUS_NAME,
- tinyjuice_bus::names::OBJECT_PATH,
- ),
- (
- "tinymcp",
- tinymcp_bus::names::INTERFACE,
- tinymcp_bus::names::OBJECT_PATH,
- ),
- (
- "tinyconnectors",
- tinyconnectors_bus::names::INTERFACE,
- tinyconnectors_bus::names::OBJECT_PATH,
- ),
- (
- "tinychannels",
- tinychannels_bus::names::BUS_NAME,
- tinychannels_bus::names::OBJECT_PATH,
- ),
- ];
- #[cfg(feature = "modules")]
- names.push(("tinybox", tinybox_bus::INTERFACE, tinybox_bus::OBJECT_PATH));
- #[cfg(feature = "documents")]
- names.push((
- "tinydocs",
- tinydocs_bus::names::BUS_NAME,
- tinydocs_bus::names::OBJECT_PATH,
- ));
- #[cfg(feature = "web3")]
- names.push((
- "tinywallet",
- tinywallet_bus::names::BUS_NAME,
- tinywallet_bus::names::OBJECT_PATH,
- ));
- #[cfg(feature = "voice")]
- names.push((
- "tinyvoice",
- tinyvoice_bus::names::BUS_NAME,
- tinyvoice_bus::names::OBJECT_PATH,
- ));
- #[cfg(feature = "hosting")]
- names.push((
- "tinyhosts",
- tinyhosts_bus::BUS_NAME,
- tinyhosts_bus::OBJECT_PATH,
- ));
- names
-}
-
-#[test]
-fn every_record_matches_its_contract_constants() {
- let contracts = contract_names();
- assert_eq!(contracts.len(), ALL.len(), "a record has no contract entry");
- for (id, bus_name, object_path) in contracts {
- let record = find(id).unwrap_or_else(|| panic!("{id} has no registry record"));
- assert_eq!(
- record.bus_name, bus_name,
- "{id} bus name drifted from its contract"
- );
- assert_eq!(
- record.object_path, object_path,
- "{id} object path drifted from its contract"
- );
- }
-}
-
-#[test]
-fn a_drifted_contract_constant_is_reported_as_a_mismatch() {
- // The comparison must be able to fail: a fixture whose constant differs
- // from the record (as a renamed upstream interface would) is not equal.
- let record = find("tinymcp").unwrap();
- let drifted = format!("{}Renamed", tinymcp_bus::names::INTERFACE);
- assert_ne!(record.bus_name, drifted);
-}
-
-#[cfg(all(
- feature = "documents",
- feature = "web3",
- feature = "voice",
- feature = "hosting"
-))]
-#[test]
-fn a_product_feature_build_carries_all_eleven_records() {
- assert_eq!(ALL.len(), 11);
- for id in [
- "tinycomputer",
- "tinysearch",
- "tinydocs",
- "tinywallet",
- "tinyjuice",
- "tinyvoice",
- "tinymcp",
- "tinyconnectors",
- "tinybox",
- "tinychannels",
- "tinyhosts",
- ] {
- assert!(find(id).is_some(), "{id} missing from the registry");
- }
-}