cli/pkg/cmd/extension/mocks.go
Kynan Ware 520482c143 Add godoc comments to exported symbols in pkg/cmd/extension
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-04 15:58:15 -07:00

61 lines
1.6 KiB
Go

package extension
import (
"github.com/cli/cli/v2/git"
"github.com/stretchr/testify/mock"
)
type mockGitClient struct {
mock.Mock
}
// CheckoutBranch mocks checking out a branch.
func (g *mockGitClient) CheckoutBranch(branch string) error {
args := g.Called(branch)
return args.Error(0)
}
// Clone mocks cloning a repository.
func (g *mockGitClient) Clone(cloneURL string, cloneArgs []string) (string, error) {
args := g.Called(cloneURL, cloneArgs)
return args.String(0), args.Error(1)
}
// CommandOutput mocks running a git command and returning its output.
func (g *mockGitClient) CommandOutput(commandArgs []string) ([]byte, error) {
args := g.Called(commandArgs)
return []byte(args.String(0)), args.Error(1)
}
// Config mocks retrieving a git configuration value.
func (g *mockGitClient) Config(name string) (string, error) {
args := g.Called(name)
return args.String(0), args.Error(1)
}
// Fetch mocks fetching refs from a remote.
func (g *mockGitClient) Fetch(remote string, refspec string) error {
args := g.Called(remote, refspec)
return args.Error(0)
}
// ForRepo mocks returning a gitClient scoped to a repository directory.
func (g *mockGitClient) ForRepo(repoDir string) gitClient {
args := g.Called(repoDir)
if v, ok := args.Get(0).(*mockGitClient); ok {
return v
}
return nil
}
// Pull mocks pulling changes from a remote branch.
func (g *mockGitClient) Pull(remote, branch string) error {
args := g.Called(remote, branch)
return args.Error(0)
}
// Remotes mocks returning the set of configured git remotes.
func (g *mockGitClient) Remotes() (git.RemoteSet, error) {
args := g.Called()
return nil, args.Error(1)
}