Skip to content

[Testing] Cover docscheck's filesystem-error branches with an error-injecting fs.FS #15

Description

@charles-fineman

Context:
Identified during work on #11
PR: #12

Description:

The QA review of #12 noted that a small set of error branches in internal/docscheck remain untested because fstest.MapFS cannot produce them naturally — they need an fs.FS that fails mid-walk or on ReadDir:

  • DocumentFiles — the fs.WalkDir callback error path and the walk's own error return
  • CheckAll — the branch that reports a failure to collect documents
  • rootEntries / CheckNamedPaths — the fs.ReadDir(".") error path

Package coverage is 94.0% after #12; these are most of the remainder.

Rationale:

Deferred from #12 as the lowest-risk gap in the package. These paths only execute if the repository root becomes unreadable mid-test, which in practice means the working tree is already broken in a way that fails the build elsewhere. The reviewer rated it "Minor... fine to defer".

Suggested approach:

A small wrapper embedding fstest.MapFS that returns a forced error from Open or ReadDir for one named path, used by two or three targeted tests. No new dependency; fstest.MapFS composes fine.

Reference:

  • internal/docscheck/docscheck.goDocumentFiles, rootEntries, CheckAll
  • internal/docscheck/docscheck_test.gorepository fixture builder to extend

Acceptance Criteria:

  • An error-injecting fs.FS wrapper exists in the package's tests
  • The WalkDir, ReadDir, and CheckAll collection-failure branches are each exercised and assert a specific message
  • Coverage of internal/docscheck does not regress

Metadata

Metadata

Labels

testingTest coverage and testing strategy

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions