test: 假模型服務的空回答兩種格式都會再問一次(clippy -D warnings 過)

上一個 commit 漏跑嚴格的 clippy:Reply::Empty 和 Fake::anthropic 沒有用到。加一個測試用它們:OpenAI 和 Anthropic 的空回答都被再問一次、第二次拿到文字。

已驗證:cargo test 全過;cargo clippy --bin anybot --all-targets -- -D warnings 過。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
王性驊 2026-11-17 11:22:11 +08:00
parent c1946a4935
commit 1437b7d9d2
1 changed files with 11 additions and 0 deletions

View File

@ -196,6 +196,17 @@ mod tests {
}
}
/// An answer with nothing in it (no words, no call) is asked again, in either format.
#[test]
fn an_empty_answer_is_asked_again() {
for (f, kind) in [(Fake::openai(vec![Reply::Empty, Reply::text("有了")]), ProviderKind::Custom), (Fake::anthropic(vec![Reply::Empty, Reply::text("有了")]), ProviderKind::Anthropic)] {
let cancel = AtomicBool::new(false);
let out = crate::providers::run_step(&req(kind, f.base()), &cancel, &|_| {}).unwrap();
assert_eq!(out.text, "有了", "{kind:?}");
assert_eq!(f.requests(), 2, "{kind:?}");
}
}
/// A busy answer with Retry-After is waited out and asked again; a dropped connection too.
#[test]
fn busy_and_dropped_answers_are_tried_again() {