Skip to content

Improve git client tests - #14351

Draft
williammartin wants to merge 1 commit into
williammartin-git-transport-testsfrom
williammartin-improve-git-tests
Draft

williammartin wants to merge 1 commit into
williammartin-git-transport-testsfrom
williammartin-improve-git-tests

Conversation

@williammartin

Copy link
Copy Markdown
Member

Description

Layers 1-3 replaced broad git.Client mocks with real local Git repositories. This follow-up makes that converted suite smaller and clearer without changing production code.

It replaces Command.Output tests that compiled temporary Go executables with the existing helper-process seam, removes an incidental URL data variation, narrows redundant remote setup, splits tables that mixed success and failure strategies, and gives parser/value tests explicit Given/When/Then structure. Distinct transport outcomes, parser equivalence classes, credential scoping and clearing, --, --ff-only, --set-upstream, and command modifier contracts remain covered.

How did you test this change?

Given the rewritten command error scenario, when I temporarily stopped Command.Output from preserving the process exit status, I saw the focused test fail with an expected status of 128 and an actual status of 0. I reverted the mutation.

Given a repository with no remote resolution metadata, when I temporarily removed the special handling for Git's no-matching-config status, I saw the focused remotes test fail with exit status 1. I reverted the mutation.

Given a git+ssh URL, when I temporarily removed that supported transport from URL classification, I saw the specific classifier scenario fail. I reverted the mutation.

Key points

  • The diff removes 67 net test lines and leaves statement coverage unchanged at 86.1%.
  • Package timing varied enough between runs that I am not claiming a wall-clock improvement, but TestOutput no longer performs two nested go build operations.
  • The tests remain in package git because parser and command-construction contracts are deliberately internal; moving them would require exporting production internals.
  • No production code changed.

Notes for reviewers

Start with git/command_test.go for the feedback-time change, then review the split parser scenarios in git/url_test.go and the reduced setup and table shape in git/client_test.go.

Parent draft: #14350.

Authorship and follow-up

Who wrote this:

  • A human wrote it.
  • An agent wrote it under close human direction.
  • An agent wrote it independently, and no human has guided the implementation beyond the initial prompt.

Who answers review comments:

  • @williammartin will read and reply directly. Name the account.
  • An agent will draft replies and @username will read them before they are posted.
  • Nobody has explicitly committed to replying.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant