Skip to content

πŸ§ͺ Test gap analysis β€” 3 new gaps found in MCP tools list and execute dispatchΒ #392

@github-actions

Description

@github-actions

Test Gap Analysis

Test suite snapshot: 1,101 unit tests, 78 integration tests (tests/compiler_tests.rs), 3 init tests, 8 MCP HTTP tests β€” 1,191 total. All pass. βœ…

Previous issue #376 is still open (3 gaps: generate_lean_prompt, init_logging, upload-workitem-attachment in tools list). The gaps below are new and not covered by #376 β€” introduced by the upload-build-artifact tool additions and execute refactor (#388).


Priority Gaps

Module Function/Path Why It Matters Suggested Test
tests/mcp_http_tests.rs test_mcp_initialize_and_tools_list β€” upload-build-artifact not asserted New tool registered in src/mcp.rs at line 993 but the tools-list test still only checks 5 of ~20 tools. A broken MCP registration would go completely undetected. Add assert!(body.contains("upload-build-artifact"), ...)
src/execute.rs No test_execute_malformed_upload_workitem_attachment_* Every other multi-step tool (update-wiki-page, comment-on-work-item, create-wiki-page) has at least one test_execute_malformed_* and test_execute_*_missing_context test exercising the dispatch path. upload-workitem-attachment has zero execute-level tests β€” the macro dispatch arm at line 315 is untested. Mirror test_execute_malformed_comment_on_work_item_returns_err for this tool
src/execute.rs No test_execute_malformed_upload_build_artifact_* Same gap as above for the newer upload-build-artifact tool (dispatch arm at line 348). All 23 existing tests for this tool live inside upload_build_artifact.rs and never invoke execute_safe_output. Mirror test_execute_malformed_update_wiki_page_returns_err for this tool

Suggested Test Cases

1. MCP tools list β€” assert upload-build-artifact is registered

// In tests/mcp_http_tests.rs, add to test_mcp_initialize_and_tools_list:
assert!(
    body.contains("upload-build-artifact"),
    "Should list upload-build-artifact tool, body: {body}"
);
// While here, also add the upload-workitem-attachment assert from #376:
assert!(
    body.contains("upload-workitem-attachment"),
    "Should list upload-workitem-attachment tool (renamed from upload-attachment in #372), body: {body}"
);

2. Execute dispatch β€” malformed JSON for upload-workitem-attachment

#[tokio::test]
async fn test_execute_malformed_upload_workitem_attachment_returns_err() {
    let dir = tempfile::tempdir().unwrap();
    let path = dir.path().join("out.ndjson");
    let line = r#"{"tool":"upload-workitem-attachment","params":{"not_valid":true}}"#;
    std::fs::write(&path, line).unwrap();

    let result = execute_safe_outputs(
        dir.path(),
        &path,
        &ExecutionContext::default(),
        false,
    )
    .await;
    assert!(result.is_err() || result.unwrap().iter().any(|r| r.is_err()));
}

3. Execute dispatch β€” missing context for upload-build-artifact

#[tokio::test]
async fn test_execute_upload_build_artifact_missing_context() {
    let dir = tempfile::tempdir().unwrap();
    let staged = dir.path().join("staged_file.txt");
    std::fs::write(&staged, b"hello").unwrap();

    let path = dir.path().join("out.ndjson");
    let line = serde_json::json!({
        "tool": "upload-build-artifact",
        "params": {
            "artifact_name": "my-artifact",
            "file_path": "staged_file.txt",
            "staged_file": "staged_file.txt",
            "sha256": "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
        }
    })
    .to_string();
    std::fs::write(&path, line).unwrap();

    // No ADO context β€” should fail gracefully (not panic)
    let result = execute_safe_output(
        "upload-build-artifact",
        &serde_json::json!({"artifact_name": "x", "file_path": "f", "staged_file": "staged_file.txt", "sha256": "abc"}),
        &ExecutionContext::default(),
        dir.path(),
        false,
    )
    .await;
    assert!(result.is_err(), "Should fail without ADO context");
}

Coverage Summary

Module Public Fns Tests Coverage Estimate
tests/mcp_http_tests.rs test_mcp_initialize_and_tools_list asserts 5/~20 registered tools Two new tools unasserted
src/execute.rs β€” upload dispatch arms 2 dispatch arms (lines 315, 348) 0 execute-level tests 0% for these arms

This issue was created by the automated test gap finder. Previous run: 2026-05-01 (#376, still open). Modules audited this cycle: all. Total tests found: 1,191 (up from 1,049 at #376 creation).

Generated by Test Gap Finder Β· ● 971.4K Β· β—·

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions