Documentation
¶
Index ¶
- Variables
- func AssertDiffContains(t *testing.T, diff string, want ...string)
- func AssertDiffNotContains(t *testing.T, diff string, unwanted ...string)
- func CreateAndCommitFile(t *testing.T, dir string, repo *git.Repository, ...)
- func CreateLargeFileWithManyHunks(t *testing.T, tmpDir string, repo *git.Repository)
- func CreateTestRepo(t *testing.T, prefix string) (string, *git.Repository, func())
- func GenerateFunction(index int, version string) string
- func RunCommand(t *testing.T, dir string, command string, args ...string) (string, error)
- func SetupTestDir(t *testing.T, dir string) func()
- type TestRepo
- func (tr *TestRepo) Chdir() func()
- func (tr *TestRepo) Cleanup()
- func (tr *TestRepo) CommitAllChanges(message string) error
- func (tr *TestRepo) CommitChanges(message string)
- func (tr *TestRepo) CreateAndCommitFile(filename, content, message string)
- func (tr *TestRepo) CreateBinaryFile(filename string, content []byte)
- func (tr *TestRepo) CreateFile(filename, content string)
- func (tr *TestRepo) CreateFileWithContent(filename, content string) error
- func (tr *TestRepo) CreateLargeFileWithManyHunks()
- func (tr *TestRepo) CreatePatchFile(filename, ref string) error
- func (tr *TestRepo) GeneratePatch(filename string)
- func (tr *TestRepo) GetCommitCount() int
- func (tr *TestRepo) GetFilePath(filename string) string
- func (tr *TestRepo) GetStagedFiles() []string
- func (tr *TestRepo) GetTempFilePath(filename string) string
- func (tr *TestRepo) ModifyFile(filename, newContent string)
- func (tr *TestRepo) RunCommand(command string, args ...string) (string, error)
- func (tr *TestRepo) RunCommandOrFail(command string, args ...string) string
- func (tr *TestRepo) WriteBinaryFile(filename string, content []byte) error
- func (tr *TestRepo) WriteFile(filename, content string) error
Constants ¶
This section is empty.
Variables ¶
var TestData = struct { // MinimalPNGTransparent is a 1x1 transparent PNG image MinimalPNGTransparent []byte // MinimalPNGRed is a 1x1 red PNG image MinimalPNGRed []byte }{ MinimalPNGTransparent: []byte{ 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x06, 0x00, 0x00, 0x00, 0x1F, 0x15, 0xC4, 0x89, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9C, 0x62, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0xE5, 0x27, 0xDE, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82, }, MinimalPNGRed: []byte{ 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x02, 0x00, 0x00, 0x00, 0x90, 0x77, 0x53, 0xDE, 0x00, 0x00, 0x00, 0x0C, 0x49, 0x44, 0x41, 0x54, 0x08, 0x99, 0x63, 0xF8, 0xCF, 0xC0, 0x00, 0x00, 0x03, 0x01, 0x01, 0x00, 0x18, 0xDD, 0x8D, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, 0x42, 0x60, 0x82, }, }
TestData contains common test data like binary files
Functions ¶
func AssertDiffContains ¶
AssertDiffContains verifies that the given diff contains all expected strings. It calls t.Helper() to ensure accurate stack traces and fails the test if any expected string is missing.
func AssertDiffNotContains ¶
AssertDiffNotContains verifies that the given diff does not contain any unwanted strings. It calls t.Helper() to ensure accurate stack traces and fails the test if any unwanted string is found.
func CreateAndCommitFile ¶
func CreateAndCommitFile(t *testing.T, dir string, repo *git.Repository, filename, content, message string)
CreateAndCommitFile creates a file with the given content and commits it (legacy function for backward compatibility)
func CreateLargeFileWithManyHunks ¶
func CreateLargeFileWithManyHunks(t *testing.T, tmpDir string, repo *git.Repository)
CreateLargeFileWithManyHunks creates a file with many functions for performance testing (legacy function for backward compatibility)
func CreateTestRepo ¶
CreateTestRepo creates a temporary directory with an initialized git repository (legacy function for backward compatibility)
func GenerateFunction ¶
GenerateFunction generates a function with the given index and version
func RunCommand ¶
RunCommand executes a command in the specified directory (legacy function for backward compatibility)
func SetupTestDir ¶
SetupTestDir changes to the test directory and returns a cleanup function (legacy function for backward compatibility)
Types ¶
type TestRepo ¶
type TestRepo struct {
Path string
Repo *git.Repository
// contains filtered or unexported fields
}
TestRepo provides a unified interface for test repositories
func NewTestRepo ¶
NewTestRepo creates a new test repository with proper initialization
func (*TestRepo) Chdir ¶
func (tr *TestRepo) Chdir() func()
Chdir changes to the repository directory and returns a cleanup function
func (*TestRepo) CommitAllChanges ¶
CommitAllChanges commits all changes with the given message
func (*TestRepo) CommitChanges ¶
CommitChanges commits all changes with the given message
func (*TestRepo) CreateAndCommitFile ¶
CreateAndCommitFile creates a file and commits it in one operation
func (*TestRepo) CreateBinaryFile ¶
CreateBinaryFile creates a binary file with the given content
func (*TestRepo) CreateFile ¶
CreateFile creates a file in the repository, creating directories as needed
func (*TestRepo) CreateFileWithContent ¶
CreateFileWithContent creates a file with content, creating directories as needed
func (*TestRepo) CreateLargeFileWithManyHunks ¶
func (tr *TestRepo) CreateLargeFileWithManyHunks()
CreateLargeFileWithManyHunks creates a file with many functions for performance testing
func (*TestRepo) CreatePatchFile ¶
CreatePatchFile creates a patch file from the current diff against the given ref
func (*TestRepo) GeneratePatch ¶
GeneratePatch generates a patch file for all changes since HEAD. This includes both staged (intent-to-add) and unstaged changes, matching the recommended workflow in CLAUDE.md for LLM agent integration.
func (*TestRepo) GetCommitCount ¶
GetCommitCount returns the number of commits in the repository
func (*TestRepo) GetFilePath ¶
GetFilePath returns the full path to a file in the repository
func (*TestRepo) GetStagedFiles ¶
GetStagedFiles returns a list of staged files
func (*TestRepo) GetTempFilePath ¶
GetTempFilePath returns a path for a temporary file in the repo
func (*TestRepo) ModifyFile ¶
ModifyFile modifies an existing file with new content
func (*TestRepo) RunCommand ¶
RunCommand executes a command in the repository directory
func (*TestRepo) RunCommandOrFail ¶
RunCommandOrFail executes a command and fails the test if it errors
func (*TestRepo) WriteBinaryFile ¶
WriteBinaryFile creates a binary file with content, creating directories as needed