From d50de7c06aa19eb6d7a54c0b522e7f80b7eae473 Mon Sep 17 00:00:00 2001 From: Alex Clarke Date: Mon, 27 Jul 2026 19:52:51 -0600 Subject: [PATCH] lint: fixed test ordering --- src/function/user_interaction.rs | 46 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/function/user_interaction.rs b/src/function/user_interaction.rs index 402129c..1d5988b 100644 --- a/src/function/user_interaction.rs +++ b/src/function/user_interaction.rs @@ -305,6 +305,29 @@ async fn handle_escalated(ctx: &RequestContext, action: &str, args: &Value) -> R } } +fn parse_options(args: &Value) -> Result> { + let raw = args + .get("options") + .ok_or_else(|| anyhow!("'options' is required and must be an array of strings"))?; + + let arr: Vec = match raw { + Value::Array(arr) => arr.clone(), + Value::String(s) => serde_json::from_str::>(s).map_err(|_| { + anyhow!( + "'options' was a string but did not parse as a JSON array. \ + Pass options as a native JSON array, e.g. [\"yes\", \"no\"]." + ) + })?, + _ => bail!("'options' is required and must be an array of strings"), + }; + + Ok(arr + .iter() + .filter_map(Value::as_str) + .map(String::from) + .collect()) +} + #[cfg(test)] mod tests { use super::*; @@ -329,26 +352,3 @@ mod tests { assert_eq!(v["options"], json!([])); } } - -fn parse_options(args: &Value) -> Result> { - let raw = args - .get("options") - .ok_or_else(|| anyhow!("'options' is required and must be an array of strings"))?; - - let arr: Vec = match raw { - Value::Array(arr) => arr.clone(), - Value::String(s) => serde_json::from_str::>(s).map_err(|_| { - anyhow!( - "'options' was a string but did not parse as a JSON array. \ - Pass options as a native JSON array, e.g. [\"yes\", \"no\"]." - ) - })?, - _ => bail!("'options' is required and must be an array of strings"), - }; - - Ok(arr - .iter() - .filter_map(Value::as_str) - .map(String::from) - .collect()) -}