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(doctor): add doctor controller tests and schemas
Steven Enamakel2bcc4080f502
diff --git a/crates/openhuman-core/src/core/all_bound_controller_tests.rs b/crates/openhuman-core/src/core/all_bound_controller_tests.rsindex 3e2e06f3cd..3fa4ef2231 100644--- a/crates/openhuman-core/src/core/all_bound_controller_tests.rs+++ b/crates/openhuman-core/src/core/all_bound_controller_tests.rs@@ -13,6 +13,7 @@ fn staged_bound_methods() -> Vec<&'static str> {let mut methods = vec!["composio.execute"];#[cfg(feature = "mcp")]methods.push("mcp_clients.registry_get");+ methods.extend(["doctor.report", "doctor.models"]);methods.extend(["encrypt.secret", "decrypt.secret"]);methods.extend(["socket.connect",@@ -678,3 +679,6 @@ mod profiles_controller_tests;#[path = "all_encryption_controller_tests.rs"]mod encryption_controller_tests;++#[path = "all_doctor_controller_tests.rs"]+mod doctor_controller_tests;diff --git a/crates/openhuman-core/src/platform/doctor/schemas.rs b/crates/openhuman-core/src/platform/doctor/schemas.rsindex 6a8fdf538f..c6bc6e65c0 100644--- a/crates/openhuman-core/src/platform/doctor/schemas.rs+++ b/crates/openhuman-core/src/platform/doctor/schemas.rs@@ -23,6 +23,11 @@ pub fn all_registered_controllers() -> Vec<RegisteredController> {]}+#[cfg(test)]+pub(crate) fn doctor_parameter_contracts() -> Vec<crate::core::all::ControllerParamContract> {+ tests::doctor_parameter_contracts()+}+pub fn schemas(function: &str) -> ControllerSchema {match function {"report" => ControllerSchema {diff --git a/crates/openhuman-core/src/platform/doctor/schemas_tests.rs b/crates/openhuman-core/src/platform/doctor/schemas_tests.rsindex da6ccf1fc7..7d8e8bbda8 100644--- a/crates/openhuman-core/src/platform/doctor/schemas_tests.rs+++ b/crates/openhuman-core/src/platform/doctor/schemas_tests.rs@@ -2,12 +2,23 @@ use super::*;use crate::core::all::assert_schema_controller_parity;#[test]-fn doctor_schema_catalog_matches_registered_controllers() {- assert_schema_controller_parity(- &all_controller_schemas(),- &all_registered_controllers(),- "report",- );+fn legacy_handlers_keep_their_identity_and_order() {+ use crate::core::all::ControllerHandler;++ let handlers: [(&str, ControllerHandler); 2] = [+ ("report", handle_report),+ ("models", handle_models),+ ];+ let controllers = all_registered_controllers();+ assert_eq!(controllers.len(), handlers.len());+ assert_eq!(all_controller_schemas().len(), handlers.len());+ assert_schema_controller_parity(&all_controller_schemas(), &controllers, "report");++ for ((function, expected_handler), controller) in handlers.iter().zip(&controllers) {+ assert_eq!(controller.schema.namespace, "doctor");+ assert_eq!(controller.schema.function, *function);+ assert!(std::ptr::fn_addr_eq(controller.handler, *expected_handler));+ }}#[test]@@ -31,7 +42,8 @@ fn optional_cache_flag_preserves_missing_null_and_boolean_values() {for (case, input, expected) in [("missing", None, None),("null", Some(Value::Null), None),- ("boolean", Some(Value::Bool(true)), Some(true)),+ ("true", Some(Value::Bool(true)), Some(true)),+ ("false", Some(Value::Bool(false)), Some(false)),] {let mut params = Map::new();if let Some(input) = input {@@ -47,8 +59,41 @@ fn optional_cache_flag_preserves_missing_null_and_boolean_values() {#[test]fn read_optional_errors_on_wrong_type() {- let mut m = Map::new();- m.insert("use_cache".into(), Value::String("yes".into()));- let err = read_optional::<bool>(&m, "use_cache").unwrap_err();- assert!(err.contains("invalid"));+ for value in [+ Value::String("true".into()),+ Value::Number(1.into()),+ Value::Array(vec![]),+ Value::Object(Map::new()),+ ] {+ let params = Map::from_iter([("use_cache".into(), value)]);+ let error = read_optional::<bool>(¶ms, "use_cache").unwrap_err();+ assert!(+ error.starts_with("invalid 'use_cache':"),+ "wrong type error keeps its field prefix: {error}"+ );+ }+}++pub(crate) fn doctor_parameter_contracts() -> Vec<crate::core::all::ControllerParamContract> {+ use serde_json::json;++ vec![+ crate::core::all::ControllerParamContract {+ method: "doctor.report",+ required: &[],+ optional: &[],+ examples: vec![json!({})],+ },+ crate::core::all::ControllerParamContract {+ method: "doctor.models",+ required: &[],+ optional: &["use_cache"],+ examples: vec![+ json!({}),+ json!({"use_cache":null}),+ json!({"use_cache":true}),+ json!({"use_cache":false}),+ ],+ },+ ]}