()
| 485 | |
| 486 | #[tokio::test] |
| 487 | async fn test_agent_permission_allow() { |
| 488 | let mock_client = Arc::new(MockLlmClient::new(vec![ |
| 489 | // First response: tool call that will be allowed |
| 490 | MockLlmClient::tool_call_response( |
| 491 | "tool-1", |
| 492 | "bash", |
| 493 | serde_json::json!({"command": "echo hello"}), |
| 494 | ), |
| 495 | // Second response: final text |
| 496 | MockLlmClient::text_response("Done!"), |
| 497 | ])); |
| 498 | |
| 499 | let tool_executor = Arc::new(ToolExecutor::new("/tmp".to_string())); |
| 500 | |
| 501 | // Create permission policy that allows echo commands |
| 502 | let permission_policy = PermissionPolicy::new() |
| 503 | .allow("bash(echo:*)") |
| 504 | .deny("bash(rm:*)"); |
| 505 | |
| 506 | let config = AgentConfig { |
| 507 | permission_checker: Some(Arc::new(permission_policy)), |
| 508 | ..Default::default() |
| 509 | }; |
| 510 | |
| 511 | let agent = AgentLoop::new( |
| 512 | mock_client.clone(), |
| 513 | tool_executor, |
| 514 | test_tool_context(), |
| 515 | config, |
| 516 | ); |
| 517 | let result = agent.execute(&[], "Echo hello", None).await.unwrap(); |
| 518 | |
| 519 | assert_eq!(result.text, "Done!"); |
| 520 | assert_eq!(result.tool_calls_count, 1); |
| 521 | } |
| 522 | |
| 523 | #[tokio::test] |
| 524 | async fn test_agent_streaming_events() { |
nothing calls this directly
no test coverage detected