Skip to content

Commit ea5bdf5

Browse files
author
luzeyang (INT)
committed
test(vision): 补 L3 空 delta 流端到端回归
execute_streaming_errors_when_model_returns_empty_delta_stream: mock 端点返回 delta-less data 事件 + [DONE],断言统一报 'no usable content' 且提示 empty delta stream,锁定 saw_data_event=true + 空内容的报错分支(原单测仅覆盖 process_sse_line 解析,未走 execute_streaming 判定)。 vision::tools 23 个用例全过。
1 parent 1173e0a commit ea5bdf5

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

crates/tui/src/vision/tools.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,32 @@ mod tests {
10311031
);
10321032
}
10331033

1034+
#[tokio::test]
1035+
async fn execute_streaming_errors_when_model_returns_empty_delta_stream() {
1036+
// L3 回归:saw_data_event=true 但所有 delta 均无 content(模型返空),
1037+
// 与端点忽略 stream 参数统一报 "no usable content",不再静默返回空
1038+
// 成功;提示语指明 empty delta stream 以区分两种成因。
1039+
let body = "data: {\"choices\":[{\"delta\":{}}]}\n\ndata: [DONE]\n\n".to_string();
1040+
let (base_url, _request_rx) = serve_once("HTTP/1.1 200 OK", body).await;
1041+
let (_tmp, ctx) = workspace_with_image();
1042+
let mut config = fake_config();
1043+
config.base_url = Some(base_url);
1044+
let tool = ImageAnalyzeTool::new(config);
1045+
1046+
let err = tool
1047+
.execute(json!({"image_path": "img.png"}), &ctx)
1048+
.await
1049+
.expect_err("empty delta stream must error instead of returning empty success");
1050+
assert!(
1051+
err.to_string().contains("no usable content"),
1052+
"error must call out the unified 'no usable content' message; got {err}"
1053+
);
1054+
assert!(
1055+
err.to_string().contains("empty delta stream"),
1056+
"error must hint at the model returning empty deltas; got {err}"
1057+
);
1058+
}
1059+
10341060
#[tokio::test]
10351061
async fn execute_non_streaming_parses_plain_json_response() {
10361062
let body =

0 commit comments

Comments
 (0)