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(core): consolidate tool schema contract tests
Steven Enamakel946844ab8cd5
diff --git a/crates/openhuman-core/src/core/all.rs b/crates/openhuman-core/src/core/all.rsindex 3b13f30795..9371185015 100644--- a/crates/openhuman-core/src/core/all.rs+++ b/crates/openhuman-core/src/core/all.rs@@ -1211,6 +1211,7 @@ pub(crate) struct ControllerSchemaContract {pub input_count: Option<usize>,pub input_order: Option<&'static [&'static str]>,pub inputs: &'static [SchemaFieldContract],+ pub output_fields: &'static [&'static str],pub outputs: Option<&'static [&'static str]>,}@@ -1234,6 +1235,14 @@ pub(crate) fn assert_schema_contract(schema: &ControllerSchema, expected: &Contrassert_eq!(field.required, required, "{}.{} input `{}` requiredness", expected.namespace, expected.function, expected.name);}}+ for output_name in expected.output_fields {+ assert!(+ schema.outputs.iter().any(|field| field.name == *output_name),+ "{}.{} is missing output `{output_name}`",+ expected.namespace,+ expected.function+ );+ }if let Some(outputs) = expected.outputs {let actual: Vec<_> = schema.outputs.iter().map(|field| field.name).collect();assert_eq!(actual, outputs, "{}.{} output names", expected.namespace, expected.function);diff --git a/crates/openhuman-core/src/tools/schemas_tests.rs b/crates/openhuman-core/src/tools/schemas_tests.rsindex ba2dc37cc5..73ee8b2ff9 100644--- a/crates/openhuman-core/src/tools/schemas_tests.rs+++ b/crates/openhuman-core/src/tools/schemas_tests.rs@@ -2,6 +2,7 @@ use super::*;use crate::tools::schemas::registry::tools_schemas;use serde_json::{json, Map};+use crate::core::all::{assert_schema_contract, ControllerSchemaContract as Contract, SchemaFieldContract as Field};const BASE_CONTROLLERS: usize = 5;#[test]@@ -28,37 +29,27 @@ fn apify_linkedin_scrape_controller_is_retired() {}#[test]-fn composio_execute_schema_shape() {- let s = tools_schemas("tools_composio_execute");- assert_eq!(s.namespace, "tools");- assert_eq!(s.function, "composio_execute");- assert!(s.inputs.iter().any(|f| f.name == "action" && f.required));-}--#[test]-fn web_answer_schema_shape() {- let s = tools_schemas("tools_web_answer");- assert_eq!(s.namespace, "tools");- assert_eq!(s.function, "web_answer");- assert!(s.inputs.iter().any(|f| f.name == "query" && f.required));- assert!(s.inputs.iter().any(|f| f.name == "depth"));- assert!(s.outputs.iter().any(|f| f.name == "citations"));-}--#[test]-fn web_contents_schema_shape() {- let s = tools_schemas("tools_web_contents");- assert_eq!(s.function, "web_contents");- assert!(s.inputs.iter().any(|f| f.name == "urls" && f.required));-}--#[test]-fn searxng_search_schema_shape() {- let s = tools_schemas("tools_searxng_search");- assert_eq!(s.namespace, "tools");- assert_eq!(s.function, "searxng_search");- assert!(s.inputs.iter().any(|f| f.name == "query" && f.required));- assert!(s.inputs.iter().any(|f| f.name == "max_results"));+fn tools_schema_wire_contracts_are_preserved() {+ let contracts: &[(&str, &[Field], &[&str])] = &[+ ("composio_execute", &[Field { name: "action", required: Some(true) }], &[]),+ ("web_answer", &[Field { name: "query", required: Some(true) }, Field { name: "depth", required: None }], &["citations"]),+ ("web_contents", &[Field { name: "urls", required: Some(true) }], &[]),+ ("searxng_search", &[Field { name: "query", required: Some(true) }, Field { name: "max_results", required: None }], &[]),+ ("web_search", &[Field { name: "query", required: Some(true) }], &["provider"]),+ ];+ for (function, inputs, outputs) in contracts {+ let contract = Contract {+ namespace: "tools",+ function: *function,+ input_count: None,+ input_order: None,+ inputs: *inputs,+ output_fields: *outputs,+ outputs: None,+ };+ let schema = tools_schemas(&format!("tools_{function}"));+ assert_schema_contract(&schema, &contract);+ }}#[test]@@ -70,13 +61,3 @@ fn optional_string_array_trims_and_drops_blank_entries() {assert_eq!(values, vec!["web", "news"]);}-#[test]-fn web_search_schema_shape() {- let s = tools_schemas("tools_web_search");- assert_eq!(s.namespace, "tools");- assert_eq!(s.function, "web_search");- assert!(s.inputs.iter().any(|f| f.name == "query" && f.required));- // The resolved search provider is part of the documented output so- // callers can attribute a managed search (#5136).- assert!(s.outputs.iter().any(|f| f.name == "provider"));-}diff --git a/crates/openhuman-core/src/web3/wallet/schemas_tests.rs b/crates/openhuman-core/src/web3/wallet/schemas_tests.rsindex 3bf8ce1fba..654178d25b 100644--- a/crates/openhuman-core/src/web3/wallet/schemas_tests.rs+++ b/crates/openhuman-core/src/web3/wallet/schemas_tests.rs@@ -26,6 +26,7 @@ fn wallet_schema_wire_contracts_are_preserved() {input_count: *input_count,input_order: *input_order,inputs: *inputs,+ output_fields: &[],outputs: None,};let schema = wallet_schemas(function);