Skip to content

Remove obsolete Git test seams - #14355

Draft
williammartin wants to merge 1 commit into
williammartin-improve-git-testsfrom
williammartin-clean-git-test-seams
Draft

williammartin wants to merge 1 commit into
williammartin-improve-git-testsfrom
williammartin-clean-git-test-seams

Conversation

@williammartin

Copy link
Copy Markdown
Member

N/A. This is the final code layer above draft PR #14351.

Description

Layers 1-4 moved Git client tests onto real local repositories and focused command assertions, but the package still carried two subprocess mock protocols and a private Client.commandContext production field used only by tests.

This removes that field and its commandCtx alias, deletes the rich JSON/environment command-mocking protocol, and replaces the remaining uses with observable real-Git state, the existing CommandModifier seam, or a narrow malformed-output parser. The one surviving subprocess helper now accepts explicit arguments instead of test-only environment variables.

How did you test this change?

Not tested manually because this is a behavior-preserving cleanup of internal test infrastructure with no user-visible command change.

Key points

  • Removed Client.commandContext, commandCtx, createCommandContext, createMockedCommandContext, TestHelperProcess, TestCommandMocking, commandResult, mockedCommands, and all GH_*HELPER_PROCESS* variables from git tests. createCommitsCommandContext and TestCommitsHelperProcess already had zero remaining definitions or callers at the layer-5 baseline.
  • Retained one focused TestGitCommandHelperProcess plus createCommand for Command.Output stdout/stderr/exit behavior and recordCommandArgs for operation-to-auth wiring. These remain necessary to protect exact credential-helper clearing/scoping, pull --ff-only, push --set-upstream, and clone host scoping without executing a fake Git path.
  • Moved RemoteURL and IsIgnored option-separator checks to observable real-Git state. Moved malformed push-revision output to a narrow parser seam. Real missing repository directories now prove arbitrary Git error propagation.
  • Preserved command modifiers, missing executable behavior, local-only Git transport coverage, literal Given/When/Then scenarios, and the layer-4 test shape.
  • Baseline git package metrics were 9.058s normal, 19.174s race, and 86.1% coverage. Final uncontended metrics were 8.074s normal, 14.688s race, and 86.4% coverage.
  • Net diff: 78 additions, 185 deletions, 107 fewer lines across 4 files.
  • Deliberately deferred moving git.IsolateConfig out of git/test.go: no existing internal test-support package fits, and introducing one would only relocate the production testing dependency while touching three consumer packages and exporting a test-only internal API.

Notes for reviewers

Start with Client.Command in git/client.go, then review the authenticated operation tests and real-Git option-boundary scenarios in git/client_test.go. This PR targets williammartin-improve-git-tests, the branch for draft PR #14351. Stack metadata is intentionally unchanged.

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