Skip to content

Add test coverage for fetch_indexes_from_main() after PR #41 refactoring #42

Description

@fullsend-ai-retro

What happened

PR #41 (merged 2026-08-06) refactored fetch_indexes_from_main() in src/doc_index.py with three substantive logic changes: (1) early return on git fetch failure with diagnostic logging, (2) replacement of full-tree git ls-tree -r scan with targeted git ls-tree origin/{branch} -- {path}, and (3) improved error messages with exit codes and sanitized stderr. The review agent (run 31114984041) correctly identified that this function has zero test coverage. Two new tests were added but they only cover the DOCS_BASE_BRANCH empty-string fallback in other functions (checkout_docs_from_base_branch and load_style_config_from_branch). The PR was merged without addressing the test coverage finding.

What could go better

The core function refactored by the PR — fetch_indexes_from_main() — has no tests exercising its new behavior. This means the three new code paths (fetch failure handling, targeted ls-tree empty result, and the diagnostic output) are validated only by the type system and manual testing. If a future change regresses the early-return logic or breaks the targeted ls-tree command construction, there is no automated safety net. Confidence is high that this is a real gap — the review agent identified it independently, and code inspection confirms zero test methods reference fetch_indexes_from_main.

Proposed change

Add unit tests for fetch_indexes_from_main() in tests/test_doc_index.py covering at minimum: (1) git fetch failure returns False and logs diagnostic with exit code and sanitized stderr, (2) targeted git ls-tree returning empty stdout returns False, (3) successful fetch + ls-tree + checkout returns True, (4) empty DOCS_BASE_BRANCH env var falls back to "main". The existing test patterns in the file (mocking run_command_safe and subprocess.run) provide a template for these tests.

Validation criteria

The fetch_indexes_from_main() function has at least 4 test cases covering the scenarios listed above. Running pytest tests/test_doc_index.py -k fetch_indexes produces passing results. Code coverage for the function's new conditional branches (fetch failure, empty ls-tree, successful path) reaches at least 80%.


Generated by retro agent from #41

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-triageRetro-filed issue awaiting triage agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions