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: consolidate billing and voice schema tests
Steven Enamakel5bf3c43d3f7a
diff --git a/crates/openhuman-core/src/voice/schemas_tests.rs b/crates/openhuman-core/src/voice/schemas_tests.rsindex a6c7a3815f..c75e459e16 100644--- a/crates/openhuman-core/src/voice/schemas_tests.rs+++ b/crates/openhuman-core/src/voice/schemas_tests.rs@@ -15,7 +15,6 @@ fn voice_schema_wire_contracts_are_preserved() {("voice_stt_dispatch", "stt_dispatch"),("voice_tts_dispatch", "tts_dispatch"),("voice_set_providers", "set_providers"),- ("voice_server_start", "server_start"),("voice_update_provider_settings", "update_provider_settings"),("voice_list_models", "list_models"),("voice_test_provider", "test_provider"),@@ -52,7 +51,6 @@ fn voice_schema_wire_contracts_are_preserved() {expect_schema_fields(&voice_schemas(key), &expected);}assert!(voice_schemas("voice_status").inputs.is_empty());- expect_schema_required_inputs(&voice_schemas("voice_server_start"), &[]);expect_schema_required_inputs(&voice_schemas("voice_update_provider_settings"), &[]);assert_schema_controller_parity(&all_voice_controller_schemas(),diff --git a/crates/openhuman-tinyhumans/src/hosted/billing/schemas_tests.rs b/crates/openhuman-tinyhumans/src/hosted/billing/schemas_tests.rsindex 206a703b60..89cedb6f90 100644--- a/crates/openhuman-tinyhumans/src/hosted/billing/schemas_tests.rs+++ b/crates/openhuman-tinyhumans/src/hosted/billing/schemas_tests.rs@@ -2,148 +2,69 @@ use super::*;use serde_json::json;#[test]-fn all_billing_controller_schemas_returns_16() {+fn billing_controller_wire_contracts_match_registration() {let schemas = all_billing_controller_schemas();- assert_eq!(schemas.len(), 16);-}--#[test]-fn all_billing_registered_controllers_returns_16() {let controllers = all_billing_registered_controllers();+ assert_eq!(schemas.len(), 16);assert_eq!(controllers.len(), 16);-}--#[test]-fn billing_schemas_get_summary() {- let s = billing_schemas("billing_get_summary");- assert_eq!(s.namespace, "billing");- assert_eq!(s.function, "get_summary");- assert!(s.inputs.is_empty());- assert!(!s.outputs.is_empty());-}--#[test]-fn billing_schemas_get_current_plan() {- let s = billing_schemas("billing_get_current_plan");- assert_eq!(s.namespace, "billing");- assert_eq!(s.function, "get_current_plan");- assert!(s.inputs.is_empty());- assert!(!s.outputs.is_empty());-}--#[test]-fn billing_schemas_get_balance() {- let s = billing_schemas("billing_get_balance");- assert_eq!(s.function, "get_balance");- assert!(s.inputs.is_empty());-}--#[test]-fn billing_schemas_purchase_plan() {- let s = billing_schemas("billing_purchase_plan");- assert_eq!(s.function, "purchase_plan");- assert_eq!(s.inputs.len(), 1);- assert_eq!(s.inputs[0].name, "plan");- assert!(s.inputs[0].required);- assert!(s.outputs.len() >= 2);-}--#[test]-fn billing_schemas_create_portal_session() {- let s = billing_schemas("billing_create_portal_session");- assert_eq!(s.function, "create_portal_session");- assert!(s.inputs.is_empty());-}--#[test]-fn billing_schemas_top_up() {- let s = billing_schemas("billing_top_up");- assert_eq!(s.function, "top_up");- assert_eq!(s.inputs.len(), 2);- assert_eq!(s.inputs[0].name, "amountUsd");- assert!(s.inputs[0].required);- assert!(!s.inputs[1].required); // gateway is optional-}--#[test]-fn billing_schemas_create_coinbase_charge() {- let s = billing_schemas("billing_create_coinbase_charge");- assert_eq!(s.function, "create_coinbase_charge");- assert_eq!(s.inputs.len(), 2);- assert!(s.outputs.len() >= 4);-}--#[test]-fn billing_schemas_get_transactions() {- let s = billing_schemas("billing_get_transactions");- assert_eq!(s.function, "get_transactions");- assert_eq!(s.inputs.len(), 2);- assert!(!s.inputs[0].required); // limit is optional- assert!(!s.inputs[1].required); // offset is optional-}--#[test]-fn billing_schemas_get_auto_recharge() {- let s = billing_schemas("billing_get_auto_recharge");- assert_eq!(s.function, "get_auto_recharge");- assert!(s.inputs.is_empty());-}--#[test]-fn billing_schemas_update_auto_recharge() {- let s = billing_schemas("billing_update_auto_recharge");- assert_eq!(s.function, "update_auto_recharge");- assert_eq!(s.inputs.len(), 1);- assert_eq!(s.inputs[0].name, "payload");-}--#[test]-fn billing_schemas_get_cards() {- let s = billing_schemas("billing_get_cards");- assert_eq!(s.function, "get_cards");- assert!(s.inputs.is_empty());-}--#[test]-fn billing_schemas_create_setup_intent() {- let s = billing_schemas("billing_create_setup_intent");- assert_eq!(s.function, "create_setup_intent");- assert!(s.inputs.is_empty());-}--#[test]-fn billing_schemas_update_card() {- let s = billing_schemas("billing_update_card");- assert_eq!(s.function, "update_card");- assert_eq!(s.inputs.len(), 2);-}--#[test]-fn billing_schemas_delete_card() {- let s = billing_schemas("billing_delete_card");- assert_eq!(s.function, "delete_card");- assert_eq!(s.inputs.len(), 1);-}--#[test]-fn billing_schemas_redeem_coupon() {- let s = billing_schemas("billing_redeem_coupon");- assert_eq!(s.function, "redeem_coupon");- assert_eq!(s.inputs.len(), 1);- assert_eq!(s.inputs[0].name, "code");-}--#[test]-fn billing_schemas_get_coupons() {- let s = billing_schemas("billing_get_coupons");- assert_eq!(s.function, "get_coupons");- assert!(s.inputs.is_empty());-}--#[test]-fn billing_schemas_unknown_function() {- let s = billing_schemas("billing_nonexistent");- assert_eq!(s.function, "unknown");+ for (schema, controller) in schemas.iter().zip(&controllers) {+ assert_eq!(schema.namespace, controller.schema.namespace);+ assert_eq!(schema.function, controller.schema.function);+ }+ for (function, input_count) in [+ ("get_summary", 0),+ ("get_current_plan", 0),+ ("get_balance", 0),+ ("purchase_plan", 1),+ ("create_portal_session", 0),+ ("top_up", 2),+ ("create_coinbase_charge", 2),+ ("get_transactions", 2),+ ("get_auto_recharge", 0),+ ("update_auto_recharge", 1),+ ("get_cards", 0),+ ("create_setup_intent", 0),+ ("update_card", 2),+ ("delete_card", 1),+ ("redeem_coupon", 1),+ ("get_coupons", 0),+ ] {+ let schema = billing_schemas(&format!("billing_{function}"));+ assert_eq!(schema.function, function);+ assert_eq!(schema.namespace, "billing");+ assert_eq!(schema.inputs.len(), input_count, "{function} input count");+ }+ for function in ["get_summary", "get_current_plan"] {+ assert!(!billing_schemas(&format!("billing_{function}"))+ .outputs+ .is_empty());+ }+ let purchase = billing_schemas("billing_purchase_plan");+ assert_eq!(purchase.inputs[0].name, "plan");+ assert!(purchase.inputs[0].required);+ assert!(purchase.outputs.len() >= 2);+ let top_up = billing_schemas("billing_top_up");+ assert_eq!(top_up.inputs[0].name, "amountUsd");+ assert!(top_up.inputs[0].required);+ assert!(!top_up.inputs[1].required);+ assert!(+ billing_schemas("billing_create_coinbase_charge")+ .outputs+ .len()+ >= 4+ );+ assert!(billing_schemas("billing_get_transactions")+ .inputs+ .iter()+ .all(|input| !input.required));+ assert_eq!(+ billing_schemas("billing_update_auto_recharge").inputs[0].name,+ "payload"+ );+ assert_eq!(+ billing_schemas("billing_redeem_coupon").inputs[0].name,+ "code"+ );}// Param deserialization tests@@ -152,7 +73,6 @@ fn billing_schemas_unknown_function() {fn deserialize_purchase_plan_params() {let params: Map<String, Value> = serde_json::from_value(json!({"plan": "pro"})).unwrap();let result = deserialize_params::<PurchasePlanParams>(params);- assert!(result.is_ok());assert_eq!(result.unwrap().plan, "pro");}@@ -160,7 +80,6 @@ fn deserialize_purchase_plan_params() {fn deserialize_top_up_params() {let params: Map<String, Value> = serde_json::from_value(json!({"amountUsd": 10.0})).unwrap();let result = deserialize_params::<TopUpParams>(params);- assert!(result.is_ok());let p = result.unwrap();assert_eq!(p.amount_usd, 10.0);assert!(p.gateway.is_none());@@ -171,7 +90,6 @@ fn deserialize_top_up_params_with_gateway() {let params: Map<String, Value> =serde_json::from_value(json!({"amountUsd": 5.0, "gateway": "stripe"})).unwrap();let result = deserialize_params::<TopUpParams>(params);- assert!(result.is_ok());assert_eq!(result.unwrap().gateway.as_deref(), Some("stripe"));}@@ -180,7 +98,6 @@ fn deserialize_coinbase_charge_params() {let params: Map<String, Value> =serde_json::from_value(json!({"plan": "enterprise", "interval": "annual"})).unwrap();let result = deserialize_params::<CoinbaseChargeParams>(params);- assert!(result.is_ok());let p = result.unwrap();assert_eq!(p.plan, "enterprise");assert_eq!(p.interval.as_deref(), Some("annual"));@@ -190,7 +107,6 @@ fn deserialize_coinbase_charge_params() {fn deserialize_transactions_params_defaults() {let params: Map<String, Value> = serde_json::from_value(json!({})).unwrap();let result = deserialize_params::<TransactionsParams>(params);- assert!(result.is_ok());let p = result.unwrap();assert!(p.limit.is_none());assert!(p.offset.is_none());@@ -201,7 +117,6 @@ fn deserialize_transactions_params_with_values() {let params: Map<String, Value> =serde_json::from_value(json!({"limit": 10, "offset": 5})).unwrap();let result = deserialize_params::<TransactionsParams>(params);- assert!(result.is_ok());let p = result.unwrap();assert_eq!(p.limit, Some(10));assert_eq!(p.offset, Some(5));@@ -212,7 +127,6 @@ fn deserialize_card_params() {let params: Map<String, Value> =serde_json::from_value(json!({"paymentMethodId": "pm_123"})).unwrap();let result = deserialize_params::<CardParams>(params);- assert!(result.is_ok());assert_eq!(result.unwrap().payment_method_id, "pm_123");}@@ -222,14 +136,12 @@ fn deserialize_update_card_params() {serde_json::from_value(json!({"paymentMethodId": "pm_1", "payload": {"default": true}})).unwrap();let result = deserialize_params::<UpdateCardParams>(params);- assert!(result.is_ok());}#[test]fn deserialize_redeem_coupon_params() {let params: Map<String, Value> = serde_json::from_value(json!({"code": "SAVE50"})).unwrap();let result = deserialize_params::<RedeemCouponParams>(params);- assert!(result.is_ok());assert_eq!(result.unwrap().code, "SAVE50");}@@ -240,52 +152,3 @@ fn deserialize_invalid_params_returns_error() {assert!(result.is_err());assert!(result.unwrap_err().contains("invalid params"));}--// Helper function tests--#[test]-fn required_string_helper() {- let f = required_string("name", "a comment");- assert_eq!(f.name, "name");- assert!(f.required);- assert!(matches!(f.ty, TypeSchema::String));-}--#[test]-fn optional_string_helper() {- let f = optional_string("gateway", "desc");- assert_eq!(f.name, "gateway");- assert!(!f.required);-}--#[test]-fn optional_u64_helper() {- let f = optional_u64("limit", "desc");- assert_eq!(f.name, "limit");- assert!(!f.required);-}--#[test]-fn json_output_helper() {- let f = json_output("result", "desc");- assert_eq!(f.name, "result");- assert!(f.required);-}--#[test]-fn output_field_helper() {- let f = output_field("url", TypeSchema::String, "desc");- assert_eq!(f.name, "url");- assert!(f.required);-}--#[test]-fn schemas_and_controllers_are_consistent() {- let schemas = all_billing_controller_schemas();- let controllers = all_billing_registered_controllers();- assert_eq!(schemas.len(), controllers.len());- for (s, c) in schemas.iter().zip(controllers.iter()) {- assert_eq!(s.namespace, c.schema.namespace);- assert_eq!(s.function, c.schema.function);- }-}