From dae6431dfc3cba6841c8d4a31883ce86a5156bbb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 8 May 2026 12:08:36 +0000 Subject: [PATCH 1/2] Initial plan From a36239f039282eebd27aaa8c49f8b3069b3ac8d5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 8 May 2026 12:12:06 +0000 Subject: [PATCH 2/2] test: add coverage for MCP tools list and upload tool execute dispatch Agent-Logs-Url: https://github.com/githubnext/ado-aw/sessions/5e191e2d-ba3d-4aff-bc93-fcef93bb03cd Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com> --- src/execute.rs | 87 +++++++++++++++++++++++++++++++++++++++++ tests/mcp_http_tests.rs | 8 ++++ 2 files changed, 95 insertions(+) diff --git a/src/execute.rs b/src/execute.rs index 583c3afa..a2c591c6 100644 --- a/src/execute.rs +++ b/src/execute.rs @@ -756,6 +756,93 @@ mod tests { assert!(result.is_err()); } + #[tokio::test] + async fn test_execute_malformed_upload_workitem_attachment_returns_err() { + // Missing required fields (work_item_id, file_path) + let entry = serde_json::json!({"name": "upload-workitem-attachment"}); + let ctx = ExecutionContext::default(); + + let result = execute_safe_output(&entry, &ctx).await; + assert!(result.is_err()); + } + + #[tokio::test] + async fn test_execute_upload_workitem_attachment_missing_context() { + let entry = serde_json::json!({ + "name": "upload-workitem-attachment", + "work_item_id": 12345, + "file_path": "report.log" + }); + + // Context without required fields (ado_org_url, etc.) + let ctx = ExecutionContext { + ado_org_url: None, + ado_organization: None, + ado_project: None, + access_token: None, + working_directory: PathBuf::from("."), + source_directory: PathBuf::from("."), + tool_configs: HashMap::new(), + repository_id: None, + repository_name: None, + allowed_repositories: HashMap::new(), + agent_stats: None, + dry_run: false, + ..Default::default() + }; + + let result = execute_safe_output(&entry, &ctx).await; + assert!(result.is_err()); + assert!( + result + .unwrap_err() + .to_string() + .contains("AZURE_DEVOPS_ORG_URL") + ); + } + + #[tokio::test] + async fn test_execute_malformed_upload_build_attachment_returns_err() { + // Missing required fields (artifact_name, file_path, staged_file, etc.) + let entry = serde_json::json!({"name": "upload-build-attachment"}); + let ctx = ExecutionContext::default(); + + let result = execute_safe_output(&entry, &ctx).await; + assert!(result.is_err()); + } + + #[tokio::test] + async fn test_execute_upload_build_attachment_missing_context() { + let entry = serde_json::json!({ + "name": "upload-build-attachment", + "artifact_name": "my-artifact", + "file_path": "staged_file.txt", + "staged_file": "staged_file.txt", + "file_size": 5_u64, + "staged_sha256": "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" + }); + + // Context without required fields (ado_org_url, etc.) + let ctx = ExecutionContext { + ado_org_url: None, + ado_organization: None, + ado_project: None, + access_token: None, + working_directory: PathBuf::from("."), + source_directory: PathBuf::from("."), + tool_configs: HashMap::new(), + repository_id: None, + repository_name: None, + allowed_repositories: HashMap::new(), + agent_stats: None, + dry_run: false, + ..Default::default() + }; + + let result = execute_safe_output(&entry, &ctx).await; + assert!(result.is_err()); + } + #[tokio::test] async fn test_execute_comment_on_work_item_missing_context() { let entry = serde_json::json!({ diff --git a/tests/mcp_http_tests.rs b/tests/mcp_http_tests.rs index 9b6b7811..56ca613d 100644 --- a/tests/mcp_http_tests.rs +++ b/tests/mcp_http_tests.rs @@ -301,6 +301,14 @@ fn test_mcp_initialize_and_tools_list() { body.contains("missing-data"), "Should list missing-data tool, body: {body}" ); + assert!( + body.contains("upload-workitem-attachment"), + "Should list upload-workitem-attachment tool, body: {body}" + ); + assert!( + body.contains("upload-build-attachment"), + "Should list upload-build-attachment tool, body: {body}" + ); } #[test]