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
fix(test): rename test files for consistency
Steven Enamakele4242bccc753
diff --git a/crates/openhuman-rpc/src/lib_tests.rs b/crates/openhuman-rpc/src/lib_tests.rsnew file mode 100644index 0000000000..9926ef9b48--- /dev/null+++ b/crates/openhuman-rpc/src/lib_tests.rs@@ -0,0 +1,87 @@+use super::*;+ use serde_json::json;++ #[test]+ fn new_preserves_value_and_logs() {+ let outcome: RpcOutcome<i64> = RpcOutcome::new(7, vec!["a".into(), "b".into()]);+ assert_eq!(outcome.value, 7);+ assert_eq!(outcome.logs, vec!["a".to_string(), "b".to_string()]);+ }++ #[test]+ fn single_log_stores_exactly_one_log() {+ let outcome = RpcOutcome::single_log(json!({"ok": true}), "hello");+ assert_eq!(outcome.logs.len(), 1);+ assert_eq!(outcome.logs[0], "hello");+ assert_eq!(outcome.value, json!({"ok": true}));+ }++ #[test]+ fn single_log_accepts_string_and_str_via_into() {+ let a = RpcOutcome::single_log(json!(1), "static str");+ let b = RpcOutcome::single_log(json!(1), String::from("owned string"));+ assert_eq!(a.logs[0], "static str");+ assert_eq!(b.logs[0], "owned string");+ }++ #[test]+ fn into_cli_compatible_json_no_logs_returns_bare_value() {+ let outcome = RpcOutcome::<serde_json::Value>::new(json!({"x": 1}), vec![]);+ let out = outcome.into_cli_compatible_json().unwrap();+ assert_eq!(out, json!({"x": 1}));+ assert!(out.get("logs").is_none());+ }++ #[test]+ fn into_cli_compatible_json_with_logs_wraps_in_envelope() {+ let outcome = RpcOutcome::single_log(json!(42), "did something");+ let out = outcome.into_cli_compatible_json().unwrap();+ assert_eq!(out["result"], json!(42));+ assert_eq!(out["logs"], json!(["did something"]));+ // And only those two keys exist.+ assert_eq!(out.as_object().unwrap().len(), 2);+ }++ #[test]+ fn into_cli_compatible_json_serializes_typed_value() {+ #[derive(serde::Serialize)]+ struct Payload<'a> {+ name: &'a str,+ count: u32,+ }+ let outcome = RpcOutcome::new(+ Payload {+ name: "atlas",+ count: 3,+ },+ vec![],+ );+ let out = outcome.into_cli_compatible_json().unwrap();+ assert_eq!(out, json!({"name": "atlas", "count": 3}));+ }++ #[test]+ fn into_cli_compatible_json_treats_null_value_as_bare_when_no_logs() {+ let outcome: RpcOutcome<Option<i32>> = RpcOutcome::new(None, vec![]);+ let out = outcome.into_cli_compatible_json().unwrap();+ assert!(out.is_null());+ }++ #[test]+ fn into_cli_compatible_json_preserves_log_order() {+ let outcome = RpcOutcome::new(+ json!({"ok": true}),+ vec!["first".into(), "second".into(), "third".into()],+ );+ let out = outcome.into_cli_compatible_json().unwrap();+ assert_eq!(out["logs"], json!(["first", "second", "third"]));+ }++ #[test]+ fn into_cli_compatible_json_empty_string_logs_still_envelope() {+ // An empty log string is still a log — envelope shape must kick in.+ let outcome = RpcOutcome::new(json!("x"), vec!["".into()]);+ let out = outcome.into_cli_compatible_json().unwrap();+ assert!(out.get("result").is_some());+ assert_eq!(out["logs"], json!([""]));+ }diff --git a/crates/openhuman-rpc/src/structured_error_tests.rs b/crates/openhuman-rpc/src/structured_error_tests.rsnew file mode 100644index 0000000000..4777c1c10a--- /dev/null+++ b/crates/openhuman-rpc/src/structured_error_tests.rs@@ -0,0 +1,38 @@+use super::*;+ use serde_json::json;++ #[test]+ fn encode_then_decode_round_trips() {+ let original = StructuredRpcError {+ message: "thread thread-123 not found".to_string(),+ data: Some(json!({ "kind": "ThreadNotFound", "thread_id": "thread-123" })),+ expected_user_state: true,+ };+ let encoded = original.encode();+ assert!(+ encoded.starts_with(STRUCTURED_RPC_ERROR_SENTINEL),+ "encoded string must carry the sentinel prefix"+ );+ let decoded = StructuredRpcError::decode(&encoded).expect("decoded");+ assert_eq!(decoded, original);+ }++ #[test]+ fn decode_returns_none_for_plain_strings() {+ assert!(StructuredRpcError::decode("plain error").is_none());+ assert!(StructuredRpcError::decode("").is_none());+ assert!(StructuredRpcError::decode("__OPENHUMAN_STRUCTURED_RPC_ERROR_V1__").is_none());+ }++ #[test]+ fn decode_returns_none_for_corrupt_envelope() {+ let bad = format!("{STRUCTURED_RPC_ERROR_SENTINEL}not-json");+ assert!(StructuredRpcError::decode(&bad).is_none());+ }++ #[test]+ fn expected_user_state_defaults_to_false_when_absent() {+ let raw = format!("{STRUCTURED_RPC_ERROR_SENTINEL}{{\"message\":\"x\",\"data\":null}}");+ let decoded = StructuredRpcError::decode(&raw).expect("decoded");+ assert!(!decoded.expected_user_state);+ }