Skip to content

test: mock repo clone git execution#3

Merged
euxaristia merged 1 commit into
mainfrom
fix/mock-repo-clone-tests
May 25, 2026
Merged

test: mock repo clone git execution#3
euxaristia merged 1 commit into
mainfrom
fix/mock-repo-clone-tests

Conversation

@euxaristia

Copy link
Copy Markdown
Owner

Summary

  • route git process execution through a package-level runner hook
  • mock git execution in repo clone tests and assert generated clone args
  • remove the real SSH/network dependency that caused CI to time out in TestRepoClone_SSH

Verification

  • env GOCACHE=/private/tmp/gitee-cli-go-build-cache GOPATH=/private/tmp/gitee-cli-go-path go test -race ./internal/cmd -run 'TestRepoClone_(SSH|WithOptions|InvalidRepo)$'

Note: full local go test ./internal/cmd still fails in this sandbox at TestNewRootCmd_ConfigLoadError, unrelated to the clone timeout.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a mockable git command runner to improve the testability of git-related operations. It refactors the existing execution logic to use this runner and adds detailed assertions in the repository clone tests to verify command arguments. Feedback focuses on enhancing the implementation's robustness and testability, specifically by moving the runner into the App struct to support parallel testing, incorporating context.Context for better process management, and using cmd.InOrStdin() for flexible input handling. Additionally, it is recommended to refactor duplicated mocking logic in tests into a shared helper function.

Comment thread internal/cmd/git.go Outdated
Comment thread internal/cmd/git.go Outdated
Comment thread internal/cmd/git.go Outdated
Comment thread internal/cmd/repo_test.go Outdated
@euxaristia euxaristia force-pushed the fix/mock-repo-clone-tests branch from f3bb77c to 1ec999d Compare May 25, 2026 14:55
@euxaristia euxaristia merged commit d880cc3 into main May 25, 2026
1 check passed
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