From 86c82b949b3da25461e72f317b0f54572ea5359f Mon Sep 17 00:00:00 2001 From: kerry Date: Wed, 30 Sep 2026 23:33:41 +0000 Subject: [PATCH] test(rust): expect structured JSON for unknown fields in redis and valkey semantic prompts Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- litellm-rust/crates/cache-redis-semantic/tests/cache.rs | 4 ++-- litellm-rust/crates/cache-valkey-semantic/tests/cache.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/litellm-rust/crates/cache-redis-semantic/tests/cache.rs b/litellm-rust/crates/cache-redis-semantic/tests/cache.rs index fa4ac00e767..dda6adc0998 100644 --- a/litellm-rust/crates/cache-redis-semantic/tests/cache.rs +++ b/litellm-rust/crates/cache-redis-semantic/tests/cache.rs @@ -509,7 +509,7 @@ fn tag_special_characters_are_escaped_in_search_filter( )] #[case::responses_output_text( SemanticCacheContext { input: Some(json!({"output_text": " result text "})), ..Default::default() }, - "result text" + "{\"output_text\":\" result text \"}" )] #[case::search_results( messages_context(vec![json!({ @@ -517,7 +517,7 @@ fn tag_special_characters_are_escaped_in_search_filter( "content": "question", "search_results": [{"source": "src", "title": "t", "content": [{"text": "found"}], "citations": {"a": 1}}], })]), - "questionsrctfound{\"a\":1}" + r#"{"role":"user","content":"question","search_results":[{"source":"src","title":"t","content":[{"text":"found"}],"citations":{"a":1}}]}"# )] #[case::empty_messages_fall_back_to_input( SemanticCacheContext { messages: Some(json!([])), input: Some(json!("fallback")), ..Default::default() }, diff --git a/litellm-rust/crates/cache-valkey-semantic/tests/cache.rs b/litellm-rust/crates/cache-valkey-semantic/tests/cache.rs index 1c693d0875d..4ac45ed0b2a 100644 --- a/litellm-rust/crates/cache-valkey-semantic/tests/cache.rs +++ b/litellm-rust/crates/cache-valkey-semantic/tests/cache.rs @@ -142,8 +142,8 @@ fn flat_dimension_info(dimension: &str) -> redis::Value { #[rstest] #[case::string_content(json!([{"content": "hello"}]), None, Some("hello"))] #[case::text_parts(json!([{"content": [{"text": "hello"}, {"text": " world"}]}]), None, Some("hello world"))] -#[case::non_object_parts_are_skipped(json!([{"content": ["raw", {"text": "hello"}]}]), None, Some("hello"))] -#[case::search_results(json!([{"search_results": [{"source": "s", "title": "t", "content": [{"text": "c"}], "citations": ["x"]}]}]), None, Some(r#"stc["x"]"#))] +#[case::string_parts_are_kept(json!([{"content": ["raw", {"text": "hello"}]}]), None, Some("rawhello"))] +#[case::search_results(json!([{"search_results": [{"source": "s", "title": "t", "content": [{"text": "c"}], "citations": ["x"]}]}]), None, Some(r#"{"search_results":[{"source":"s","title":"t","content":[{"text":"c"}],"citations":["x"]}]}"#))] #[case::responses_string_input(json!([]), Some(json!(" hello ")), Some("hello"))] #[case::responses_item_input(json!([]), Some(json!([{"content": "first"}, {"text": "second"}])), Some("first\nsecond"))] #[case::blank_input(json!([]), Some(json!(" ")), None)]