From 2b8842917c65201a6c76ee117792ca3fce1bd77b Mon Sep 17 00:00:00 2001 From: Randolf Jung Date: Wed, 25 Feb 2026 03:23:21 -0800 Subject: [PATCH 1/2] chore: format code --- src/config.rs | 10 ++++- src/mcp/mod.rs | 6 ++- src/secrets/resolvers/azure.rs | 1 - src/template/catalog.rs | 25 ++++++++--- tests/auth_profiles.rs | 7 ++- tests/bash_streaming.rs | 7 ++- tests/cli_args.rs | 12 ++++-- tests/cli_templates.rs | 3 +- tests/expression_binder.rs | 2 +- tests/http_decode_extract_transport.rs | 13 ++++-- tests/secrets_vault.rs | 4 +- tests/streaming_decode_extract.rs | 59 +++++++++++++++++++++----- 12 files changed, 117 insertions(+), 32 deletions(-) diff --git a/src/config.rs b/src/config.rs index 9111bd7..92be09c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -394,7 +394,10 @@ clock_skew_seconds = 60 #[test] fn jwt_config_audience_parsed_from_toml() { - assert_eq!(jwt_with_explicit_fields().audience, "https://api.example.com"); + assert_eq!( + jwt_with_explicit_fields().audience, + "https://api.example.com" + ); } #[test] @@ -415,7 +418,10 @@ clock_skew_seconds = 60 #[test] fn jwt_config_explicit_algorithms_parsed_from_toml() { - assert_eq!(jwt_with_explicit_fields().algorithms, vec!["RS256", "ES256"]); + assert_eq!( + jwt_with_explicit_fields().algorithms, + vec!["RS256", "ES256"] + ); } #[test] diff --git a/src/mcp/mod.rs b/src/mcp/mod.rs index 0b014e1..eb1d716 100644 --- a/src/mcp/mod.rs +++ b/src/mcp/mod.rs @@ -1302,7 +1302,11 @@ mod tests { .expect("response"); let result = response.result.expect("result"); let tools = result["tools"].as_array().expect("tools array"); - assert!(tools.iter().any(|t| t["name"] == DISCOVERY_SEARCH_TOOL_NAME)); + assert!( + tools + .iter() + .any(|t| t["name"] == DISCOVERY_SEARCH_TOOL_NAME) + ); } #[tokio::test] diff --git a/src/secrets/resolvers/azure.rs b/src/secrets/resolvers/azure.rs index d3d44bc..2995e2f 100644 --- a/src/secrets/resolvers/azure.rs +++ b/src/secrets/resolvers/azure.rs @@ -710,5 +710,4 @@ mod tests { fn path_traversal_in_azure_id_returns_error() { validate_azure_id("../../../etc/passwd", "tenant").unwrap_err(); } - } diff --git a/src/template/catalog.rs b/src/template/catalog.rs index a5059d5..37af929 100644 --- a/src/template/catalog.rs +++ b/src/template/catalog.rs @@ -84,7 +84,10 @@ mod tests { use super::super::schema::{Annotations, CommandTemplate, OperationTemplate}; let mut prod_vars = BTreeMap::new(); - prod_vars.insert("base_url".to_string(), "https://api.example.com".to_string()); + prod_vars.insert( + "base_url".to_string(), + "https://api.example.com".to_string(), + ); let mut envs = BTreeMap::new(); envs.insert("production".to_string(), prod_vars); @@ -146,7 +149,12 @@ mod tests { #[cfg(feature = "bash")] fn catalog_preserves_provider_environment_default() { let catalog = catalog_with_provider_environments(); - let envs = catalog.get("myservice.ping").unwrap().provider_environments.as_ref().unwrap(); + let envs = catalog + .get("myservice.ping") + .unwrap() + .provider_environments + .as_ref() + .unwrap(); assert_eq!(envs.default.as_deref(), Some("production")); } @@ -154,8 +162,15 @@ mod tests { #[cfg(feature = "bash")] fn catalog_preserves_provider_environment_variables() { let catalog = catalog_with_provider_environments(); - let envs = catalog.get("myservice.ping").unwrap().provider_environments.as_ref().unwrap(); - assert_eq!(envs.environments["production"]["base_url"], "https://api.example.com"); + let envs = catalog + .get("myservice.ping") + .unwrap() + .provider_environments + .as_ref() + .unwrap(); + assert_eq!( + envs.environments["production"]["base_url"], + "https://api.example.com" + ); } - } diff --git a/tests/auth_profiles.rs b/tests/auth_profiles.rs index 14ac3d9..03d2617 100644 --- a/tests/auth_profiles.rs +++ b/tests/auth_profiles.rs @@ -67,7 +67,12 @@ async fn oidc_resolved_profile() -> earl::auth::profiles::ResolvedOAuthProfile { #[tokio::test] async fn oidc_discovery_populates_authorization_url() { let resolved = oidc_resolved_profile().await; - assert!(resolved.authorization_url.unwrap().contains("/oauth/authorize")); + assert!( + resolved + .authorization_url + .unwrap() + .contains("/oauth/authorize") + ); } #[tokio::test] diff --git a/tests/bash_streaming.rs b/tests/bash_streaming.rs index 3741261..dfe5b00 100644 --- a/tests/bash_streaming.rs +++ b/tests/bash_streaming.rs @@ -58,7 +58,12 @@ async fn collect_output(mut rx: mpsc::Receiver) -> String { async fn collect_chunks(mut rx: mpsc::Receiver) -> Vec { let mut chunks = vec![]; while let Some(chunk) = rx.recv().await { - chunks.push(String::from_utf8(chunk.data).unwrap().trim_end().to_string()); + chunks.push( + String::from_utf8(chunk.data) + .unwrap() + .trim_end() + .to_string(), + ); } chunks } diff --git a/tests/cli_args.rs b/tests/cli_args.rs index 9f26bda..e1441b7 100644 --- a/tests/cli_args.rs +++ b/tests/cli_args.rs @@ -1,4 +1,4 @@ -use earl::expression::cli_args::{parse_cli_args, CliArgsError}; +use earl::expression::cli_args::{CliArgsError, parse_cli_args}; use earl::template::schema::{ParamSpec, ParamType}; fn s(v: &str) -> String { @@ -93,7 +93,10 @@ fn parses_boolean_flag_without_value() { ) .unwrap(); - assert_eq!(expr.named_args[1], ("verbose".to_string(), serde_json::json!(true))); + assert_eq!( + expr.named_args[1], + ("verbose".to_string(), serde_json::json!(true)) + ); } #[test] @@ -106,7 +109,10 @@ fn parses_boolean_flag_with_explicit_false() { ) .unwrap(); - assert_eq!(expr.named_args[1], ("verbose".to_string(), serde_json::json!(false))); + assert_eq!( + expr.named_args[1], + ("verbose".to_string(), serde_json::json!(false)) + ); } #[test] diff --git a/tests/cli_templates.rs b/tests/cli_templates.rs index 1b9f667..ba2a7b2 100644 --- a/tests/cli_templates.rs +++ b/tests/cli_templates.rs @@ -978,8 +978,7 @@ fn templates_list_json_write_mode_output_includes_expected_command() { let rows = parsed.as_array().unwrap(); assert!(!rows.is_empty()); assert_eq!( - rows[0]["command"], - "github.create_issue", + rows[0]["command"], "github.create_issue", "github.create_issue should be present in write-mode listings" ); } diff --git a/tests/expression_binder.rs b/tests/expression_binder.rs index 6598554..bff5e32 100644 --- a/tests/expression_binder.rs +++ b/tests/expression_binder.rs @@ -1,5 +1,5 @@ use earl::expression::ast::CallExpression; -use earl::expression::binder::{bind_arguments, BindError}; +use earl::expression::binder::{BindError, bind_arguments}; use earl::template::schema::{ParamSpec, ParamType}; fn params() -> Vec { diff --git a/tests/http_decode_extract_transport.rs b/tests/http_decode_extract_transport.rs index 2cd19b8..7549e00 100644 --- a/tests/http_decode_extract_transport.rs +++ b/tests/http_decode_extract_transport.rs @@ -13,7 +13,9 @@ fn auto_decode_json_content_type_returns_json_body() { let json_bytes = br#"{"ok":true}"#; let decoded = decode_response(ResultDecode::Auto, Some("application/json"), json_bytes).unwrap(); - let DecodedBody::Json(value) = decoded else { panic!("expected JSON") }; + let DecodedBody::Json(value) = decoded else { + panic!("expected JSON") + }; assert_eq!(value["ok"], json!(true)); } @@ -21,7 +23,9 @@ fn auto_decode_json_content_type_returns_json_body() { fn auto_decode_text_content_type_returns_text_body() { let text_bytes = b"hello"; let decoded = decode_response(ResultDecode::Auto, Some("text/plain"), text_bytes).unwrap(); - let DecodedBody::Text(value) = decoded else { panic!("expected text") }; + let DecodedBody::Text(value) = decoded else { + panic!("expected text") + }; assert_eq!(value, "hello"); } @@ -179,7 +183,10 @@ fn transport_retry_max_attempts_clamped_to_minimum() { #[test] fn transport_retry_on_status_resolved_from_template() { - assert_eq!(resolved_override_transport().retry_on_status, vec![429, 500]); + assert_eq!( + resolved_override_transport().retry_on_status, + vec![429, 500] + ); } #[test] diff --git a/tests/secrets_vault.rs b/tests/secrets_vault.rs index 2b123e0..a65ef2e 100644 --- a/tests/secrets_vault.rs +++ b/tests/secrets_vault.rs @@ -47,7 +47,9 @@ fn missing_vault_credentials_returns_error() { let _token = EnvRestore::remove("VAULT_TOKEN"); let resolver = VaultResolver::new(); - resolver.resolve("vault://secret/myapp#api_key").unwrap_err(); + resolver + .resolve("vault://secret/myapp#api_key") + .unwrap_err(); } #[test] diff --git a/tests/streaming_decode_extract.rs b/tests/streaming_decode_extract.rs index 8b875a3..eda4f10 100644 --- a/tests/streaming_decode_extract.rs +++ b/tests/streaming_decode_extract.rs @@ -26,7 +26,9 @@ fn streaming_json_chunk_is_independently_decodable() { &chunk.data, ) .unwrap(); - let DecodedBody::Json(v) = decoded else { panic!("expected DecodedBody::Json") }; + let DecodedBody::Json(v) = decoded else { + panic!("expected DecodedBody::Json") + }; assert_eq!(v, json!({"msg": "hello"})); } @@ -41,7 +43,12 @@ fn streaming_json_pointer_extract_returns_value_at_specified_path() { json_pointer: "/data/id".to_string(), }; - let decoded = decode_response(ResultDecode::Json, chunk.content_type.as_deref(), &chunk.data).unwrap(); + let decoded = decode_response( + ResultDecode::Json, + chunk.content_type.as_deref(), + &chunk.data, + ) + .unwrap(); assert_eq!(extract_result(Some(&extract), &decoded).unwrap(), json!(1)); } @@ -58,8 +65,16 @@ fn streaming_regex_extract_returns_first_capture_group_from_chunk() { regex: r"event_id=([a-z0-9-]+)".to_string(), }; - let decoded = decode_response(ResultDecode::Text, chunk.content_type.as_deref(), &chunk.data).unwrap(); - assert_eq!(extract_result(Some(&extract), &decoded).unwrap(), json!("abc-001")); + let decoded = decode_response( + ResultDecode::Text, + chunk.content_type.as_deref(), + &chunk.data, + ) + .unwrap(); + assert_eq!( + extract_result(Some(&extract), &decoded).unwrap(), + json!("abc-001") + ); } // ── Auto decode ────────────────────────────────────────── @@ -77,7 +92,9 @@ fn streaming_auto_decode_infers_json_from_content_type() { &chunk.data, ) .unwrap(); - let DecodedBody::Json(v) = decoded else { panic!("expected DecodedBody::Json") }; + let DecodedBody::Json(v) = decoded else { + panic!("expected DecodedBody::Json") + }; assert_eq!(v, json!({"ok": true})); } @@ -94,7 +111,9 @@ fn streaming_auto_decode_infers_text_from_content_type() { &chunk.data, ) .unwrap(); - let DecodedBody::Text(v) = decoded else { panic!("expected DecodedBody::Text") }; + let DecodedBody::Text(v) = decoded else { + panic!("expected DecodedBody::Text") + }; assert_eq!(v, "plain text line"); } @@ -111,7 +130,9 @@ fn streaming_auto_decode_falls_back_to_json_for_valid_json_without_content_type( &chunk.data, ) .unwrap(); - let DecodedBody::Json(v) = decoded else { panic!("expected DecodedBody::Json") }; + let DecodedBody::Json(v) = decoded else { + panic!("expected DecodedBody::Json") + }; assert_eq!(v, json!({"key": "value"})); } @@ -148,8 +169,16 @@ fn streaming_css_selector_extract_returns_matching_element_text() { css_selector: "span.val".to_string(), }; - let decoded = decode_response(ResultDecode::Html, chunk.content_type.as_deref(), &chunk.data).unwrap(); - assert_eq!(extract_result(Some(&extract), &decoded).unwrap(), json!(["100"])); + let decoded = decode_response( + ResultDecode::Html, + chunk.content_type.as_deref(), + &chunk.data, + ) + .unwrap(); + assert_eq!( + extract_result(Some(&extract), &decoded).unwrap(), + json!(["100"]) + ); } // ── XML / XPath chunks ────────────────────────────────── @@ -165,8 +194,16 @@ fn streaming_xpath_extract_returns_text_node_values() { xpath: "//item/text()".to_string(), }; - let decoded = decode_response(ResultDecode::Xml, chunk.content_type.as_deref(), &chunk.data).unwrap(); - assert_eq!(extract_result(Some(&extract), &decoded).unwrap(), json!(["alpha"])); + let decoded = decode_response( + ResultDecode::Xml, + chunk.content_type.as_deref(), + &chunk.data, + ) + .unwrap(); + assert_eq!( + extract_result(Some(&extract), &decoded).unwrap(), + json!(["alpha"]) + ); } // ── Binary chunks ──────────────────────────────────────── From d72233fca8545e16478a0c8bf99a8882ec7400e4 Mon Sep 17 00:00:00 2001 From: Randolf Jung Date: Wed, 25 Feb 2026 03:30:11 -0800 Subject: [PATCH 2/2] fix: correct rerank mock indices in search_service test BTreeMap iterates in alphabetical key order, so github.create_issue (index 0) comes before github.search_issues (index 1). The mock was returning index 1 with score 0.99, which mapped to search_issues, not create_issue as intended. Co-Authored-By: Claude Sonnet 4.6 --- tests/search_service.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/search_service.rs b/tests/search_service.rs index 5ab6c5f..7ffbe44 100644 --- a/tests/search_service.rs +++ b/tests/search_service.rs @@ -83,8 +83,8 @@ async fn prefers_remote_results_when_remote_search_succeeds() { when.method(POST).path("/rerank"); then.status(200).json_body_obj(&serde_json::json!({ "data": [ - {"index": 1, "score": 0.99}, - {"index": 0, "score": 0.75} + {"index": 0, "score": 0.99}, + {"index": 1, "score": 0.75} ] })); })