Skip to content

test: add unit tests for internal/patterns and internal/gitignore #10

Description

@puremachinery

Context

internal/patterns currently has no tests, and internal/gitignore also has no test file.

These two packages are not the same kind of test target:

  • internal/patterns is straightforward pure matching logic
  • internal/gitignore is a thin wrapper around git check-ignore plus an in-memory cache

That means the tests should reflect the real implementation rather than treating both packages as pure parsers.

Proposed change

Add test coverage for both packages.

internal/patterns

Cover:

  • Basic glob matching
  • Recursive ** behavior
  • * and ? matching
  • Empty-pattern behavior and other edge cases

internal/gitignore

Cover:

  • Behavior against a temporary git repo with real .gitignore files
  • Ignored vs non-ignored paths using git check-ignore
  • Behavior when git is unavailable or unusable, if practical to simulate
  • Cache behavior at a basic level (for example, repeated calls for the same repo root)

Use Go's built-in testing package.

Why this is a good first issue

  • The scope is still fairly self-contained
  • internal/patterns is an especially approachable unit-test target
  • internal/gitignore is a good introduction to how this repo wraps existing system tools

Relevant files

  • internal/patterns/
  • internal/gitignore/

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

    good first issueGood for newcomerstestingTest coverage or test infrastructure

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions