minio-rs/.claude/commands/check-coverage.md
Henk-Jan Lebbink ec0e79214f
refactor: consolidate codebase structure and add testing infrastructure (#194)
Reorganize project structure to improve maintainability and add comprehensive
  testing documentation and tooling support.
2025-11-19 11:09:22 -08:00

3.3 KiB

Check Test Coverage

Analyze code coverage for the MinIO Rust SDK and provide a detailed report.

Your Task

  1. Install cargo-llvm-cov if needed

    • Check if llvm-cov is installed: cargo llvm-cov --version
    • If not installed: cargo install cargo-llvm-cov
    • This tool works well on Windows and all platforms
  2. Run Coverage Analysis

    • First try: cargo llvm-cov --lib --tests (includes unit tests only)
    • Try to also include integration tests: cargo llvm-cov --all-targets --tests
    • For HTML report: cargo llvm-cov --lib --tests --html --output-dir target/coverage
    • For detailed output: cargo llvm-cov --lib --tests --text
    • Focus on library code, not test code itself
    • Important: Integration tests in tests/ directory may cover API functions and client operations
  3. Parse and Present Results

    • Show overall coverage percentage (from both unit and integration tests)
    • List files with their coverage percentages
    • Identify files/functions with <100% coverage
    • Highlight critical uncovered code paths in src/madmin and src/s3
    • Separate coverage by module (madmin vs s3)
    • Note: Report which coverage comes from unit tests vs integration tests
    • Call out API/client methods that are covered by integration tests
  4. Provide Actionable Report Present findings in this format:

    ## Coverage Summary
    - Overall: XX.XX% (from unit + integration tests combined)
    - Unit Test Coverage: XX.XX%
    - Integration Test Coverage: XX.XX%
    - Lines covered: XXXX / XXXX
    - Functions covered: XXX / XXX
    
    ### Module Breakdown
    - src/madmin: XX.XX% (XXXX/XXXX lines) [Unit XX% / Integration XX%]
    - src/s3: XX.XX% (XXXX/XXXX lines) [Unit XX% / Integration XX%]
    
    ## API/Client Methods Covered by Integration Tests
    - src/s3/client/put_object.rs - covered by integration tests
    - src/s3/response/list_objects.rs - covered by integration tests
    - [List all methods with integration test coverage]
    
    ## Files Below 100% Coverage
    
    ### MinIO Admin (madmin)
    #### src/madmin/builders/some_file.rs (XX.XX%)
    - Line 45-52: Error handling path not tested (both unit and integration)
    - Line 78: Builder method combination not covered
    
    #### src/madmin/response/other_file.rs (XX.XX%)
    - Line 23-25: JSON parsing error path missing test
    
    ### S3 API (s3)
    #### src/s3/client.rs (XX.XX%)
    - Line 123-130: Error handling for network failures
    - Line 245: Retry logic not tested
    
    #### src/s3/args/some_arg.rs (XX.XX%)
    - Line 67-70: Validation edge case
    
    ## Recommendations
    1. [madmin] Add test for error case in some_file.rs:45-52
    2. [madmin] Test builder method combinations in some_file.rs:78
    3. [s3] Add network failure test in client.rs:123-130
    4. [s3] Test validation edge case in args/some_arg.rs:67-70
    5. Investigate which integration tests are failing and fix them to improve coverage
    
  5. Suggest Next Steps

    • Recommend which tests to write first (prioritize critical paths)
    • Indicate which API methods ARE covered by integration tests vs which are not
    • Note which integration tests are failing/skipped and why
    • Suggest whether to run /test-coverage to auto-generate tests for uncovered paths
    • Identify if any coverage gaps are in trivial code that can be ignored

Do not make any code changes - only analyze and report.