#![allow(clippy::unwrap_used)]
use embacle::{FunctionCall, ToolCallRequest};
use serde_json::json;
#[test]
fn function_call_round_trips_through_json() {
let call = FunctionCall {
name: "get_activities".to_owned(),
args: json!({"limit": 10, "provider": "strava", "filters": {"sport": ["run", "ride"]}}),
};
let wire = serde_json::to_value(&call).unwrap();
assert_eq!(
wire,
json!({"name": "get_activities", "args": {"limit": 10, "provider": "strava", "filters": {"sport": ["run", "ride"]}}})
);
let back: FunctionCall = serde_json::from_value(wire).unwrap();
assert_eq!(back.name, call.name);
assert_eq!(back.args, call.args);
let tc: ToolCallRequest = back.into();
assert_eq!(tc.function_name, "get_activities");
assert_eq!(tc.arguments["filters"]["sport"][1], "ride");
}