chore: clean up dead code, fix broken test

- Remove unused methods: append_response_text, clear_response,
  has_pending_function_calls, take_function_calls
- Add #[allow(dead_code)] for intentionally kept future-use methods
  and response modification helpers
- Remove unused now_unix import from gemini.rs
- Fix test_modify_strips_all_tools: tools key is removed entirely
  when no custom tools provided, not left as empty array
- Zero warnings, 32 tests passing
This commit is contained in:
Nikketryhard
2026-02-15 01:14:51 -06:00
parent 981fb3b18d
commit 735c3e357d
4 changed files with 13 additions and 41 deletions

View File

@@ -635,9 +635,9 @@ mod tests {
let modified = modify_request(&bytes, None).unwrap();
let result: Value = serde_json::from_slice(&modified).unwrap();
let tools = result["request"]["tools"].as_array().unwrap();
// With no ToolContext, tools should just be stripped (empty)
assert!(tools.is_empty(), "all tools should be stripped");
// With no ToolContext, tools should be removed entirely
assert!(result["request"]["tools"].is_null() || result.pointer("/request/tools").is_none(),
"tools should be removed when no custom tools provided");
}
#[test]
@@ -734,6 +734,7 @@ mod tests {
// ─── Response modification ──────────────────────────────────────────────────
/// Rewrite an SSE response chunk to replace `functionCall` parts with text,
#[allow(dead_code)]
/// so the LS doesn't see tool calls for tools it doesn't manage.
///
/// The MITM intercept layer has already captured the function call data
@@ -810,6 +811,7 @@ pub fn modify_response_chunk(chunk: &[u8]) -> Option<Vec<u8>> {
}
}
#[allow(dead_code)]
/// Find the end of a JSON object starting at the given string.
/// Returns the index past the closing brace.
fn find_json_end(s: &str) -> Option<usize> {
@@ -845,6 +847,7 @@ fn find_json_end(s: &str) -> Option<usize> {
None
}
#[allow(dead_code)]
/// Rebuild chunked encoding from a modified response body.
/// Takes the full text (which contains old chunk sizes) and rebuilds
/// with correct sizes.
@@ -881,6 +884,7 @@ fn rechunk_response(text: &str) -> String {
///
/// Handles both Gemini public API format (`{"candidates":[...]}`) and
/// internal LS format (`{"response":{"candidates":[...]}}`).
#[allow(dead_code)]
fn rewrite_function_calls_in_response(json: &mut Value) -> bool {
let mut changed = false;