()
| 1181 | |
| 1182 | #[test] |
| 1183 | fn applies_magic_string_cache_control() { |
| 1184 | let mut body = json!({ |
| 1185 | "messages": [ |
| 1186 | { |
| 1187 | "role":"user", |
| 1188 | "content":[ |
| 1189 | { |
| 1190 | "type":"text", |
| 1191 | "text": format!("hello {} world", MAGIC_TRIGGER_5M_ID) |
| 1192 | } |
| 1193 | ] |
| 1194 | } |
| 1195 | ] |
| 1196 | }); |
| 1197 | |
| 1198 | apply_magic_string_cache_control_triggers(&mut body); |
| 1199 | |
| 1200 | let block = &body["messages"][0]["content"][0]; |
| 1201 | assert_eq!(block["cache_control"]["type"], json!("ephemeral")); |
| 1202 | assert_eq!(block["cache_control"]["ttl"], json!("5m")); |
| 1203 | assert!( |
| 1204 | !block["text"] |
| 1205 | .as_str() |
| 1206 | .unwrap() |
| 1207 | .contains(MAGIC_TRIGGER_5M_ID) |
| 1208 | ); |
| 1209 | } |
| 1210 | |
| 1211 | #[test] |
| 1212 | fn skips_magic_string_cache_control_for_empty_text_blocks() { |
nothing calls this directly
no test coverage detected