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:
parent
c1946a4935
commit
1437b7d9d2
|
|
@ -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.
|
/// A busy answer with Retry-After is waited out and asked again; a dropped connection too.
|
||||||
#[test]
|
#[test]
|
||||||
fn busy_and_dropped_answers_are_tried_again() {
|
fn busy_and_dropped_answers_are_tried_again() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue