Documentation
¶
Overview ¶
Package testutil provides test helpers for git repository testing.
Index ¶
- type ComparisonTest
- type GitTestRepo
- func (r *GitTestRepo) CommitAll(msg string)
- func (r *GitTestRepo) Diff() string
- func (r *GitTestRepo) DiffCached() string
- func (r *GitTestRepo) FileExists(path string) bool
- func (r *GitTestRepo) Git(args ...string) string
- func (r *GitTestRepo) GitMayFail(args ...string) (string, error)
- func (r *GitTestRepo) ReadFile(path string) string
- func (r *GitTestRepo) StageFile(path string)
- func (r *GitTestRepo) WriteFile(path, content string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ComparisonTest ¶
type ComparisonTest struct {
Expected *GitTestRepo
Actual *GitTestRepo
// contains filtered or unexported fields
}
ComparisonTest represents a comparison between two git operations. Used to verify hunk produces identical results to manual git operations.
func NewComparisonTest ¶
func NewComparisonTest( t *testing.T, setup func(r *GitTestRepo), ) *ComparisonTest
NewComparisonTest creates two identical repos for comparison testing. The setup function is called on both repos to establish identical state.
func (*ComparisonTest) AssertSameContent ¶
func (c *ComparisonTest) AssertSameContent(paths ...string)
AssertSameContent verifies both repos have identical file contents.
func (*ComparisonTest) AssertSameDiff ¶
func (c *ComparisonTest) AssertSameDiff()
AssertSameDiff verifies both repos have identical staged diffs.
func (*ComparisonTest) AssertSameUnstagedDiff ¶
func (c *ComparisonTest) AssertSameUnstagedDiff()
AssertSameUnstagedDiff verifies both repos have identical unstaged diffs.
type GitTestRepo ¶
type GitTestRepo struct {
Dir string
// contains filtered or unexported fields
}
GitTestRepo creates a temporary git repository for testing.
func NewGitTestRepo ¶
func NewGitTestRepo(t *testing.T) *GitTestRepo
NewGitTestRepo creates a new test repo with git initialized.
func (*GitTestRepo) CommitAll ¶
func (r *GitTestRepo) CommitAll(msg string)
CommitAll stages and commits all changes.
func (*GitTestRepo) Diff ¶
func (r *GitTestRepo) Diff() string
Diff returns the current unstaged diff.
func (*GitTestRepo) DiffCached ¶
func (r *GitTestRepo) DiffCached() string
DiffCached returns the current staged diff.
func (*GitTestRepo) FileExists ¶
func (r *GitTestRepo) FileExists(path string) bool
FileExists checks if a file exists in the repo.
func (*GitTestRepo) Git ¶
func (r *GitTestRepo) Git(args ...string) string
Git runs a git command in the test repo.
func (*GitTestRepo) GitMayFail ¶
func (r *GitTestRepo) GitMayFail(args ...string) (string, error)
GitMayFail runs a git command that may fail, returning the error.
func (*GitTestRepo) ReadFile ¶
func (r *GitTestRepo) ReadFile(path string) string
ReadFile reads a file from the repo.
func (*GitTestRepo) StageFile ¶
func (r *GitTestRepo) StageFile(path string)
StageFile stages a specific file.
func (*GitTestRepo) WriteFile ¶
func (r *GitTestRepo) WriteFile(path, content string)
WriteFile creates or overwrites a file in the repo.