From 1437b7d9d2311634490983e382746e6815f19107 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A7=E9=A9=8A?= Date: Tue, 17 Nov 2026 11:22:11 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E5=81=87=E6=A8=A1=E5=9E=8B=E6=9C=8D?= =?UTF-8?q?=E5=8B=99=E7=9A=84=E7=A9=BA=E5=9B=9E=E7=AD=94=E5=85=A9=E7=A8=AE?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E9=83=BD=E6=9C=83=E5=86=8D=E5=95=8F=E4=B8=80?= =?UTF-8?q?=E6=AC=A1=EF=BC=88clippy=20-D=20warnings=20=E9=81=8E=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 上一個 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 --- src/testkit.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/testkit.rs b/src/testkit.rs index c9b31b7..3ada89d 100644 --- a/src/testkit.rs +++ b/src/testkit.rs @@ -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() {