gittest

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package gittest provides shared test doubles for the git package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockClient

type MockClient struct {
	StatusFunc         func(ctx context.Context) ([]git.FileStatus, error)
	DiffFunc           func(ctx context.Context, opts git.DiffOpts) ([]git.FileDiff, error)
	LogFunc            func(ctx context.Context, opts git.LogOpts) ([]git.Commit, error)
	BlameFunc          func(ctx context.Context, path string) ([]git.BlameLine, error)
	RepoRootFunc       func(ctx context.Context) (string, error)
	IsRepoFunc         func(ctx context.Context) (bool, error)
	DiffTreeFilesFunc  func(ctx context.Context, hash string) ([]string, error)
	DiffFileNamesFunc  func(ctx context.Context, commitA, commitB string) ([]string, error)
	StageFunc          func(ctx context.Context, paths []string) error
	UnstageFunc        func(ctx context.Context, paths []string) error
	StageHunkFunc      func(ctx context.Context, path string, hunk git.Hunk) error
	UnstageHunkFunc    func(ctx context.Context, path string, hunk git.Hunk) error
	StageLineFunc      func(ctx context.Context, path string, hunk git.Hunk, lineIdx int) error
	UnstageLineFunc    func(ctx context.Context, path string, hunk git.Hunk, lineIdx int) error
	CommitFunc         func(ctx context.Context, msg string, opts git.CommitOpts) (string, error)
	BranchListFunc     func(ctx context.Context) ([]git.Branch, error)
	CurrentBranchFunc  func(ctx context.Context) (git.Branch, error)
	BranchCreateFunc   func(ctx context.Context, name, base string) error
	BranchDeleteFunc   func(ctx context.Context, name string, force bool) error
	BranchRenameFunc   func(ctx context.Context, oldName, newName string) error
	CheckoutFunc       func(ctx context.Context, ref string) error
	PushFunc           func(ctx context.Context, opts git.PushOpts) error
	PullFunc           func(ctx context.Context, opts git.PullOpts) error
	FetchFunc          func(ctx context.Context, opts git.FetchOpts) error
	RemoteListFunc     func(ctx context.Context) ([]git.Remote, error)
	RemoteAddFunc      func(ctx context.Context, name, url string) error
	RemoteRemoveFunc   func(ctx context.Context, name string) error
	WorktreeListFunc   func(ctx context.Context) ([]git.Worktree, error)
	WorktreeAddFunc    func(ctx context.Context, path, branch string) error
	WorktreeRemoveFunc func(ctx context.Context, path string, force bool) error
	StashListFunc      func(ctx context.Context) ([]git.StashEntry, error)
	StashShowFunc      func(ctx context.Context, index int) (string, error)
	StashPushFunc      func(ctx context.Context, opts git.StashOpts) error
	StashPopFunc       func(ctx context.Context, index int) error
	StashApplyFunc     func(ctx context.Context, index int) error
	StashDropFunc      func(ctx context.Context, index int) error
	TagListFunc        func(ctx context.Context) ([]git.Tag, error)
	TagCreateFunc      func(ctx context.Context, name, ref, message string) error
	TagDeleteFunc      func(ctx context.Context, name string) error
	TagListRemoteFunc  func(ctx context.Context, remote string) ([]git.Tag, error)
	TagPushFunc        func(ctx context.Context, remote, name string) error
	TagPushAllFunc     func(ctx context.Context, remote string) error
	MergeFunc          func(ctx context.Context, branch string, opts git.MergeOpts) error
	MergeAbortFunc     func(ctx context.Context) error
	RebaseFunc         func(ctx context.Context, onto string, opts git.RebaseOpts) error
	RebaseContinueFunc func(ctx context.Context) error
	RebaseAbortFunc    func(ctx context.Context) error
	CherryPickFunc     func(ctx context.Context, commitHash string) error
	BisectStartFunc    func(ctx context.Context, bad, good string) error
	BisectGoodFunc     func(ctx context.Context) (string, error)
	BisectBadFunc      func(ctx context.Context) (string, error)
	BisectResetFunc    func(ctx context.Context) error
	ReflogFunc         func(ctx context.Context, ref string, limit int) ([]git.ReflogEntry, error)
	DiscardFileFunc    func(ctx context.Context, path string) error
	DiscardAllFunc     func(ctx context.Context) error
	RevertFunc         func(ctx context.Context, hash string) error
	RevertContinueFunc func(ctx context.Context) error
	RevertAbortFunc    func(ctx context.Context) error
	ResetFunc          func(ctx context.Context, ref string, mode git.ResetMode) error
}

MockClient is a test double implementing git.GitClient. Each method has a corresponding exported function field; if non-nil the field is called, otherwise the method returns zero values.

func (*MockClient) BisectBad

func (m *MockClient) BisectBad(ctx context.Context) (string, error)

func (*MockClient) BisectGood

func (m *MockClient) BisectGood(ctx context.Context) (string, error)

func (*MockClient) BisectReset

func (m *MockClient) BisectReset(ctx context.Context) error

func (*MockClient) BisectStart

func (m *MockClient) BisectStart(ctx context.Context, bad, good string) error

func (*MockClient) Blame

func (m *MockClient) Blame(ctx context.Context, path string) ([]git.BlameLine, error)

func (*MockClient) BranchCreate

func (m *MockClient) BranchCreate(ctx context.Context, name, base string) error

func (*MockClient) BranchDelete

func (m *MockClient) BranchDelete(ctx context.Context, name string, force bool) error

func (*MockClient) BranchList

func (m *MockClient) BranchList(ctx context.Context) ([]git.Branch, error)

func (*MockClient) BranchRename

func (m *MockClient) BranchRename(ctx context.Context, oldName, newName string) error

func (*MockClient) Checkout

func (m *MockClient) Checkout(ctx context.Context, ref string) error

func (*MockClient) CherryPick

func (m *MockClient) CherryPick(ctx context.Context, commitHash string) error

func (*MockClient) Commit

func (m *MockClient) Commit(ctx context.Context, msg string, opts git.CommitOpts) (string, error)

func (*MockClient) CurrentBranch

func (m *MockClient) CurrentBranch(ctx context.Context) (git.Branch, error)

func (*MockClient) Diff

func (m *MockClient) Diff(ctx context.Context, opts git.DiffOpts) ([]git.FileDiff, error)

func (*MockClient) DiffFileNames

func (m *MockClient) DiffFileNames(ctx context.Context, commitA, commitB string) ([]string, error)

func (*MockClient) DiffTreeFiles

func (m *MockClient) DiffTreeFiles(ctx context.Context, hash string) ([]string, error)

func (*MockClient) DiscardAllUnstaged

func (m *MockClient) DiscardAllUnstaged(ctx context.Context) error

func (*MockClient) DiscardFile

func (m *MockClient) DiscardFile(ctx context.Context, path string) error

func (*MockClient) Fetch

func (m *MockClient) Fetch(ctx context.Context, opts git.FetchOpts) error

func (*MockClient) IsRepo

func (m *MockClient) IsRepo(ctx context.Context) (bool, error)

func (*MockClient) Log

func (m *MockClient) Log(ctx context.Context, opts git.LogOpts) ([]git.Commit, error)

func (*MockClient) Merge

func (m *MockClient) Merge(ctx context.Context, branch string, opts git.MergeOpts) error

func (*MockClient) MergeAbort

func (m *MockClient) MergeAbort(ctx context.Context) error

func (*MockClient) Pull

func (m *MockClient) Pull(ctx context.Context, opts git.PullOpts) error

func (*MockClient) Push

func (m *MockClient) Push(ctx context.Context, opts git.PushOpts) error

func (*MockClient) Rebase

func (m *MockClient) Rebase(ctx context.Context, onto string, opts git.RebaseOpts) error

func (*MockClient) RebaseAbort

func (m *MockClient) RebaseAbort(ctx context.Context) error

func (*MockClient) RebaseContinue

func (m *MockClient) RebaseContinue(ctx context.Context) error

func (*MockClient) Reflog

func (m *MockClient) Reflog(ctx context.Context, ref string, limit int) ([]git.ReflogEntry, error)

func (*MockClient) RemoteAdd

func (m *MockClient) RemoteAdd(ctx context.Context, name, url string) error

func (*MockClient) RemoteList

func (m *MockClient) RemoteList(ctx context.Context) ([]git.Remote, error)

func (*MockClient) RemoteRemove

func (m *MockClient) RemoteRemove(ctx context.Context, name string) error

func (*MockClient) RepoRoot

func (m *MockClient) RepoRoot(ctx context.Context) (string, error)

func (*MockClient) Reset

func (m *MockClient) Reset(ctx context.Context, ref string, mode git.ResetMode) error

func (*MockClient) Revert

func (m *MockClient) Revert(ctx context.Context, hash string) error

func (*MockClient) RevertAbort

func (m *MockClient) RevertAbort(ctx context.Context) error

func (*MockClient) RevertContinue

func (m *MockClient) RevertContinue(ctx context.Context) error

func (*MockClient) Stage

func (m *MockClient) Stage(ctx context.Context, paths []string) error

func (*MockClient) StageHunk

func (m *MockClient) StageHunk(ctx context.Context, path string, hunk git.Hunk) error

func (*MockClient) StageLine

func (m *MockClient) StageLine(ctx context.Context, path string, hunk git.Hunk, lineIdx int) error

func (*MockClient) StashApply

func (m *MockClient) StashApply(ctx context.Context, index int) error

func (*MockClient) StashDrop

func (m *MockClient) StashDrop(ctx context.Context, index int) error

func (*MockClient) StashList

func (m *MockClient) StashList(ctx context.Context) ([]git.StashEntry, error)

func (*MockClient) StashPop

func (m *MockClient) StashPop(ctx context.Context, index int) error

func (*MockClient) StashPush

func (m *MockClient) StashPush(ctx context.Context, opts git.StashOpts) error

func (*MockClient) StashShow

func (m *MockClient) StashShow(ctx context.Context, index int) (string, error)

func (*MockClient) Status

func (m *MockClient) Status(ctx context.Context) ([]git.FileStatus, error)

func (*MockClient) TagCreate

func (m *MockClient) TagCreate(ctx context.Context, name, ref, message string) error

func (*MockClient) TagDelete

func (m *MockClient) TagDelete(ctx context.Context, name string) error

func (*MockClient) TagList

func (m *MockClient) TagList(ctx context.Context) ([]git.Tag, error)

func (*MockClient) TagListRemote

func (m *MockClient) TagListRemote(ctx context.Context, remote string) ([]git.Tag, error)

func (*MockClient) TagPush

func (m *MockClient) TagPush(ctx context.Context, remote, name string) error

func (*MockClient) TagPushAll

func (m *MockClient) TagPushAll(ctx context.Context, remote string) error

func (*MockClient) Unstage

func (m *MockClient) Unstage(ctx context.Context, paths []string) error

func (*MockClient) UnstageHunk

func (m *MockClient) UnstageHunk(ctx context.Context, path string, hunk git.Hunk) error

func (*MockClient) UnstageLine

func (m *MockClient) UnstageLine(ctx context.Context, path string, hunk git.Hunk, lineIdx int) error

func (*MockClient) WorktreeAdd

func (m *MockClient) WorktreeAdd(ctx context.Context, path, branch string) error

func (*MockClient) WorktreeList

func (m *MockClient) WorktreeList(ctx context.Context) ([]git.Worktree, error)

func (*MockClient) WorktreeRemove

func (m *MockClient) WorktreeRemove(ctx context.Context, path string, force bool) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL