style(tests): apply rustfmt to brittle-test hardening changes
This commit is contained in:
parent
45cdd25b3d
commit
431287184b
4 changed files with 68 additions and 17 deletions
|
|
@ -363,7 +363,10 @@ async fn turn_returns_text_when_no_tools_called() {
|
||||||
);
|
);
|
||||||
|
|
||||||
let response = agent.turn("hi").await.unwrap();
|
let response = agent.turn("hi").await.unwrap();
|
||||||
assert!(!response.is_empty(), "Expected non-empty text response from provider");
|
assert!(
|
||||||
|
!response.is_empty(),
|
||||||
|
"Expected non-empty text response from provider"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ═══════════════════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════════════════
|
||||||
|
|
@ -388,7 +391,10 @@ async fn turn_executes_single_tool_then_returns() {
|
||||||
);
|
);
|
||||||
|
|
||||||
let response = agent.turn("run echo").await.unwrap();
|
let response = agent.turn("run echo").await.unwrap();
|
||||||
assert!(!response.is_empty(), "Expected non-empty response after tool execution");
|
assert!(
|
||||||
|
!response.is_empty(),
|
||||||
|
"Expected non-empty response after tool execution"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ═══════════════════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════════════════
|
||||||
|
|
@ -425,7 +431,10 @@ async fn turn_handles_multi_step_tool_chain() {
|
||||||
);
|
);
|
||||||
|
|
||||||
let response = agent.turn("count 3 times").await.unwrap();
|
let response = agent.turn("count 3 times").await.unwrap();
|
||||||
assert!(!response.is_empty(), "Expected non-empty response after multi-step chain");
|
assert!(
|
||||||
|
!response.is_empty(),
|
||||||
|
"Expected non-empty response after multi-step chain"
|
||||||
|
);
|
||||||
assert_eq!(*count.lock().unwrap(), 3);
|
assert_eq!(*count.lock().unwrap(), 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -486,7 +495,10 @@ async fn turn_handles_unknown_tool_gracefully() {
|
||||||
);
|
);
|
||||||
|
|
||||||
let response = agent.turn("use nonexistent").await.unwrap();
|
let response = agent.turn("use nonexistent").await.unwrap();
|
||||||
assert!(!response.is_empty(), "Expected non-empty response after unknown tool recovery");
|
assert!(
|
||||||
|
!response.is_empty(),
|
||||||
|
"Expected non-empty response after unknown tool recovery"
|
||||||
|
);
|
||||||
|
|
||||||
// Verify the tool result mentioned "Unknown tool"
|
// Verify the tool result mentioned "Unknown tool"
|
||||||
let has_tool_result = agent.history().iter().any(|msg| match msg {
|
let has_tool_result = agent.history().iter().any(|msg| match msg {
|
||||||
|
|
@ -523,7 +535,10 @@ async fn turn_recovers_from_tool_failure() {
|
||||||
);
|
);
|
||||||
|
|
||||||
let response = agent.turn("try failing tool").await.unwrap();
|
let response = agent.turn("try failing tool").await.unwrap();
|
||||||
assert!(!response.is_empty(), "Expected non-empty response after tool failure recovery");
|
assert!(
|
||||||
|
!response.is_empty(),
|
||||||
|
"Expected non-empty response after tool failure recovery"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
|
@ -544,7 +559,10 @@ async fn turn_recovers_from_tool_error() {
|
||||||
);
|
);
|
||||||
|
|
||||||
let response = agent.turn("try panicking").await.unwrap();
|
let response = agent.turn("try panicking").await.unwrap();
|
||||||
assert!(!response.is_empty(), "Expected non-empty response after tool error recovery");
|
assert!(
|
||||||
|
!response.is_empty(),
|
||||||
|
"Expected non-empty response after tool error recovery"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ═══════════════════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════════════════
|
||||||
|
|
@ -665,7 +683,10 @@ async fn xml_dispatcher_parses_and_loops() {
|
||||||
);
|
);
|
||||||
|
|
||||||
let response = agent.turn("test xml").await.unwrap();
|
let response = agent.turn("test xml").await.unwrap();
|
||||||
assert!(!response.is_empty(), "Expected non-empty response from XML dispatcher");
|
assert!(
|
||||||
|
!response.is_empty(),
|
||||||
|
"Expected non-empty response from XML dispatcher"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
|
@ -746,7 +767,10 @@ async fn turn_preserves_text_alongside_tool_calls() {
|
||||||
);
|
);
|
||||||
|
|
||||||
let response = agent.turn("check something").await.unwrap();
|
let response = agent.turn("check something").await.unwrap();
|
||||||
assert!(!response.is_empty(), "Expected non-empty final response after mixed text+tool");
|
assert!(
|
||||||
|
!response.is_empty(),
|
||||||
|
"Expected non-empty final response after mixed text+tool"
|
||||||
|
);
|
||||||
|
|
||||||
// The intermediate text should be in history
|
// The intermediate text should be in history
|
||||||
let has_intermediate = agent.history().iter().any(|msg| match msg {
|
let has_intermediate = agent.history().iter().any(|msg| match msg {
|
||||||
|
|
@ -792,7 +816,10 @@ async fn turn_handles_multiple_tools_in_one_response() {
|
||||||
);
|
);
|
||||||
|
|
||||||
let response = agent.turn("batch").await.unwrap();
|
let response = agent.turn("batch").await.unwrap();
|
||||||
assert!(!response.is_empty(), "Expected non-empty response after multi-tool batch");
|
assert!(
|
||||||
|
!response.is_empty(),
|
||||||
|
"Expected non-empty response after multi-tool batch"
|
||||||
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
*count.lock().unwrap(),
|
*count.lock().unwrap(),
|
||||||
3,
|
3,
|
||||||
|
|
@ -1264,5 +1291,8 @@ async fn run_single_delegates_to_turn() {
|
||||||
let mut agent = build_agent_with(provider, vec![], Box::new(NativeToolDispatcher));
|
let mut agent = build_agent_with(provider, vec![], Box::new(NativeToolDispatcher));
|
||||||
|
|
||||||
let response = agent.run_single("test").await.unwrap();
|
let response = agent.run_single("test").await.unwrap();
|
||||||
assert!(!response.is_empty(), "Expected non-empty response from run_single");
|
assert!(
|
||||||
|
!response.is_empty(),
|
||||||
|
"Expected non-empty response from run_single"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -643,7 +643,10 @@ mod tests {
|
||||||
|
|
||||||
let (success, output) = run_agent_job(&config, &job).await;
|
let (success, output) = run_agent_job(&config, &job).await;
|
||||||
assert!(!success, "Agent job without provider key should fail");
|
assert!(!success, "Agent job without provider key should fail");
|
||||||
assert!(!output.is_empty(), "Expected non-empty error output from failed agent job");
|
assert!(
|
||||||
|
!output.is_empty(),
|
||||||
|
"Expected non-empty error output from failed agent job"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
|
|
|
||||||
|
|
@ -761,7 +761,10 @@ mod tests {
|
||||||
// The error should be about git (not about autonomy/read-only mode)
|
// The error should be about git (not about autonomy/read-only mode)
|
||||||
assert!(!result.success, "Expected failure due to missing git repo");
|
assert!(!result.success, "Expected failure due to missing git repo");
|
||||||
let error_msg = result.error.as_deref().unwrap_or("");
|
let error_msg = result.error.as_deref().unwrap_or("");
|
||||||
assert!(!error_msg.is_empty(), "Expected a git-related error message");
|
assert!(
|
||||||
|
!error_msg.is_empty(),
|
||||||
|
"Expected a git-related error message"
|
||||||
|
);
|
||||||
assert!(
|
assert!(
|
||||||
!error_msg.contains("read-only") && !error_msg.contains("autonomy"),
|
!error_msg.contains("read-only") && !error_msg.contains("autonomy"),
|
||||||
"Error should be about git, not about autonomy restrictions: {error_msg}"
|
"Error should be about git, not about autonomy restrictions: {error_msg}"
|
||||||
|
|
|
||||||
|
|
@ -222,7 +222,10 @@ async fn e2e_single_tool_call_cycle() {
|
||||||
|
|
||||||
let mut agent = build_agent(provider, vec![Box::new(EchoTool)]);
|
let mut agent = build_agent(provider, vec![Box::new(EchoTool)]);
|
||||||
let response = agent.turn("run echo").await.unwrap();
|
let response = agent.turn("run echo").await.unwrap();
|
||||||
assert!(!response.is_empty(), "Expected non-empty response after tool execution");
|
assert!(
|
||||||
|
!response.is_empty(),
|
||||||
|
"Expected non-empty response after tool execution"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validates multi-step tool chain: tool A → tool B → tool C → final response.
|
/// Validates multi-step tool chain: tool A → tool B → tool C → final response.
|
||||||
|
|
@ -246,7 +249,10 @@ async fn e2e_multi_step_tool_chain() {
|
||||||
|
|
||||||
let mut agent = build_agent(provider, vec![Box::new(counting_tool)]);
|
let mut agent = build_agent(provider, vec![Box::new(counting_tool)]);
|
||||||
let response = agent.turn("count twice").await.unwrap();
|
let response = agent.turn("count twice").await.unwrap();
|
||||||
assert!(!response.is_empty(), "Expected non-empty response after tool chain");
|
assert!(
|
||||||
|
!response.is_empty(),
|
||||||
|
"Expected non-empty response after tool chain"
|
||||||
|
);
|
||||||
assert_eq!(*count.lock().unwrap(), 2);
|
assert_eq!(*count.lock().unwrap(), 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -268,7 +274,10 @@ async fn e2e_xml_dispatcher_tool_call() {
|
||||||
|
|
||||||
let mut agent = build_agent_xml(provider, vec![Box::new(EchoTool)]);
|
let mut agent = build_agent_xml(provider, vec![Box::new(EchoTool)]);
|
||||||
let response = agent.turn("test xml dispatch").await.unwrap();
|
let response = agent.turn("test xml dispatch").await.unwrap();
|
||||||
assert!(!response.is_empty(), "Expected non-empty response from XML dispatcher");
|
assert!(
|
||||||
|
!response.is_empty(),
|
||||||
|
"Expected non-empty response from XML dispatcher"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validates that multiple sequential turns maintain conversation coherence.
|
/// Validates that multiple sequential turns maintain conversation coherence.
|
||||||
|
|
@ -308,7 +317,10 @@ async fn e2e_unknown_tool_recovery() {
|
||||||
|
|
||||||
let mut agent = build_agent(provider, vec![Box::new(EchoTool)]);
|
let mut agent = build_agent(provider, vec![Box::new(EchoTool)]);
|
||||||
let response = agent.turn("call missing tool").await.unwrap();
|
let response = agent.turn("call missing tool").await.unwrap();
|
||||||
assert!(!response.is_empty(), "Expected non-empty response after unknown tool recovery");
|
assert!(
|
||||||
|
!response.is_empty(),
|
||||||
|
"Expected non-empty response after unknown tool recovery"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validates parallel tool dispatch in a single response.
|
/// Validates parallel tool dispatch in a single response.
|
||||||
|
|
@ -334,6 +346,9 @@ async fn e2e_parallel_tool_dispatch() {
|
||||||
|
|
||||||
let mut agent = build_agent(provider, vec![Box::new(counting_tool)]);
|
let mut agent = build_agent(provider, vec![Box::new(counting_tool)]);
|
||||||
let response = agent.turn("run both").await.unwrap();
|
let response = agent.turn("run both").await.unwrap();
|
||||||
assert!(!response.is_empty(), "Expected non-empty response after parallel dispatch");
|
assert!(
|
||||||
|
!response.is_empty(),
|
||||||
|
"Expected non-empty response after parallel dispatch"
|
||||||
|
);
|
||||||
assert_eq!(*count.lock().unwrap(), 2);
|
assert_eq!(*count.lock().unwrap(), 2);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue