Skip to content

test: add unit tests for internal/filescan #96

Description

@sorafujitani

Context

internal/filescan/parallel.go is the shared parallel file-scanning utility used by the file-backed backends, but it has no dedicated test file. Its contract (result ordering, filtering, bounded concurrency) is currently only exercised indirectly through backend tests.

Task

  1. Read internal/filescan/parallel.go and identify the exported API and its documented/implied contract.
  2. Create internal/filescan/parallel_test.go with table-driven tests covering at least:
    • results preserve input order regardless of goroutine completion order (use a callback that sleeps inversely to index to force out-of-order completion)
    • empty input returns empty/nil without spawning work
    • items the callback rejects (keep=false or error, per the actual API) are dropped while others survive
    • single-item input
    • input larger than the concurrency limit (e.g. 100 items) completes fully
  3. Ensure the ordering test would actually fail if order were broken (verify by temporarily breaking the implementation locally).

Acceptance criteria

  • go test ./internal/filescan passes.
  • go test -race ./internal/filescan passes (add it to the test invocation locally; CI already runs the suite).
  • No changes to non-test code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomersimpact: lowLower or indirect user-visible impact

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions