mirror of
https://github.com/instructkr/claw-code.git
synced 2026-11-19 00:00:00 +08:00
test(cli): assert streamed response is emitted once
This commit is contained in:
1 parent
971d350e53
commit
811403286b
1 file changed
+9
-9
@@ -130,7 +130,7 @@ fn compact_flag_streaming_text_only_emits_final_message_text() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn text_prompt_mode_prints_final_assistant_text_after_spinner() {
|
fn text_prompt_mode_streams_assistant_text_once_before_spinner_completion() {
|
||||||
// given a workspace pointed at the mock Anthropic service running the
|
// given a workspace pointed at the mock Anthropic service running the
|
||||||
// streaming_text scenario which only emits a single assistant text block
|
// streaming_text scenario which only emits a single assistant text block
|
||||||
let runtime = tokio::runtime::Runtime::new().expect("tokio runtime should build");
|
let runtime = tokio::runtime::Runtime::new().expect("tokio runtime should build");
|
||||||
@@ -162,7 +162,7 @@ fn text_prompt_mode_prints_final_assistant_text_after_spinner() {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
// then stdout should contain the final assistant text, not just spinner output
|
// then the streamed answer should appear once before the spinner completion
|
||||||
assert!(
|
assert!(
|
||||||
output.status.success(),
|
output.status.success(),
|
||||||
"text prompt run should succeed\nstdout:\n{}\n\nstderr:\n{}",
|
"text prompt run should succeed\nstdout:\n{}\n\nstderr:\n{}",
|
||||||
@@ -171,19 +171,19 @@ fn text_prompt_mode_prints_final_assistant_text_after_spinner() {
|
|||||||
);
|
);
|
||||||
let stdout = String::from_utf8(output.stdout).expect("stdout should be utf8");
|
let stdout = String::from_utf8(output.stdout).expect("stdout should be utf8");
|
||||||
let plain_stdout = strip_ansi_codes(&stdout);
|
let plain_stdout = strip_ansi_codes(&stdout);
|
||||||
assert!(
|
let assistant_text = "Mock streaming says hello from the parity harness.";
|
||||||
plain_stdout.contains("Mock streaming says hello from the parity harness."),
|
assert_eq!(
|
||||||
"text prompt stdout should include the assistant text ({stdout:?})"
|
plain_stdout.matches(assistant_text).count(),
|
||||||
|
1,
|
||||||
|
"text prompt stdout should contain the streamed assistant text exactly once ({stdout:?})"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
plain_stdout.contains("✔ ✨ Done"),
|
plain_stdout.contains("✔ ✨ Done"),
|
||||||
"text prompt stdout should still include spinner completion ({stdout:?})"
|
"text prompt stdout should still include spinner completion ({stdout:?})"
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
plain_stdout
|
plain_stdout.find(assistant_text) < plain_stdout.find("✔ ✨ Done"),
|
||||||
.lines()
|
"text prompt stdout should stream the assistant text before spinner completion ({stdout:?})"
|
||||||
.any(|line| line == "Mock streaming says hello from the parity harness."),
|
|
||||||
"text prompt stdout should print the assistant text as its own line ({stdout:?})"
|
|
||||||
);
|
);
|
||||||
|
|
||||||
fs::remove_dir_all(&workspace).expect("workspace cleanup should succeed");
|
fs::remove_dir_all(&workspace).expect("workspace cleanup should succeed");
|
||||||
|
|||||||
Reference in new issue
Block a user