Documentation
¶
Index ¶
- Variables
- type GitTestEnv
- func (env *GitTestEnv) AssertBranchDoesNotExist(commitRef string)
- func (env *GitTestEnv) AssertBranchExists(commitRef string)
- func (env *GitTestEnv) AssertCommitMessageEquals(expectedMessage, commitRef string, depth ...int)
- func (env *GitTestEnv) AssertCurrentBranchEquals(expectedBranch string)
- func (env *GitTestEnv) AssertFileEquals(path, expectedContent, commitRef string, depth ...int)
- func (env *GitTestEnv) AssertTagEquals(expectedTag, commitRef string, depth ...int)
- func (env *GitTestEnv) AssertVersionEquals(templatePath, expectedVersion, commitRef string, depth ...int)
- func (env *GitTestEnv) CommitFile(name string, content []byte, commitRef string)
- func (env *GitTestEnv) CommitFileFromTemplate(templatePath, bindingValue, commitRef string)
- func (env *GitTestEnv) CreateBranch(branch string, commitRef ...string)
- func (env *GitTestEnv) ExecuteGit(args ...string) string
- func (env *GitTestEnv) ExecuteGitAllowError(args ...string) (string, error)
- func (env *GitTestEnv) ExecuteGitflow(args ...string) string
- type SetupTestEnvOption
Constants ¶
This section is empty.
Variables ¶
var ( WithProductionBranch = func(branch string) SetupTestEnvOption { return func(opts *testEnvOptions) { opts.productionBranch = branch } } WithDevelopmentBranch = func(branch string) SetupTestEnvOption { return func(opts *testEnvOptions) { opts.developmentBranch = branch } } WithReleaseBranch = func(prefix string) SetupTestEnvOption { return func(opts *testEnvOptions) { opts.releaseBranch = prefix } } WithHotfixBranch = func(prefix string) SetupTestEnvOption { return func(opts *testEnvOptions) { opts.hotfixBranch = prefix } } )
TestEnvOption functions to customize test environment setup
Functions ¶
This section is empty.
Types ¶
type GitTestEnv ¶
type GitTestEnv struct {
LocalPath string // Path to local repository
RemotePath string // Path to simulated remote repository
// contains filtered or unexported fields
}
GitTestEnv manages local repository and simulated remote repository
func SetupTestEnv ¶
func SetupTestEnv(t *testing.T, options ...SetupTestEnvOption) *GitTestEnv
SetupTestEnv creates test environment with local repo and simulated remote
func (*GitTestEnv) AssertBranchDoesNotExist ¶
func (env *GitTestEnv) AssertBranchDoesNotExist(commitRef string)
AssertBranchDoesNotExist checks that a branch does not exist
func (*GitTestEnv) AssertBranchExists ¶
func (env *GitTestEnv) AssertBranchExists(commitRef string)
AssertBranchExists checks if a branch exists
func (*GitTestEnv) AssertCommitMessageEquals ¶
func (env *GitTestEnv) AssertCommitMessageEquals(expectedMessage, commitRef string, depth ...int)
AssertCommitMessageEquals checks if the first line of the commit message at the given branch and depth matches the expected message depth specifies which commit to retrieve: 0 = HEAD (latest), 1 = HEAD~1 (previous commit), etc.
func (*GitTestEnv) AssertCurrentBranchEquals ¶
func (env *GitTestEnv) AssertCurrentBranchEquals(expectedBranch string)
AssertCurrentBranchEquals checks if the currently checked out branch matches the expected branch name
func (*GitTestEnv) AssertFileEquals ¶
func (env *GitTestEnv) AssertFileEquals(path, expectedContent, commitRef string, depth ...int)
AssertFileEquals checks if a file in a branch has the expected content If comparing a template file ending with .tpl, it will check the {{.Version}} placeholder against expectedContent depth specifies which commit to retrieve: 0 = HEAD (latest), 1 = HEAD~1 (previous commit), etc.
func (*GitTestEnv) AssertTagEquals ¶
func (env *GitTestEnv) AssertTagEquals(expectedTag, commitRef string, depth ...int)
AssertTagEquals checks if the tag at the given branch and depth matches the expected tag depth specifies which commit to retrieve: 0 = HEAD (latest), 1 = HEAD~1 (previous commit), etc.
func (*GitTestEnv) AssertVersionEquals ¶
func (env *GitTestEnv) AssertVersionEquals(templatePath, expectedVersion, commitRef string, depth ...int)
AssertVersionEquals checks if the version in a file matches the expected version It renders the template both with the expected version and with a special marker, then compares the difference to extract the version from the actual file
func (*GitTestEnv) CommitFile ¶ added in v1.2.0
func (env *GitTestEnv) CommitFile(name string, content []byte, commitRef string)
CommitFile creates a file with the specified content in the repository, commits it, and pushes it to the remote. The commit message is automatically generated based on the branch name
func (*GitTestEnv) CommitFileFromTemplate ¶
func (env *GitTestEnv) CommitFileFromTemplate(templatePath, bindingValue, commitRef string)
CommitFileFromTemplate creates a file using a template with variables, adds it, commits it, and pushes it to the remote The filename will be derived from the template name (e.g., template "version.txt.tpl" creates file "version.txt") The commit message is automatically generated based on the branch name
func (*GitTestEnv) CreateBranch ¶
func (env *GitTestEnv) CreateBranch(branch string, commitRef ...string)
CreateBranch creates a new branch from the specified base branch
func (*GitTestEnv) ExecuteGit ¶
func (env *GitTestEnv) ExecuteGit(args ...string) string
ExecuteGit runs a git command in the local repository
func (*GitTestEnv) ExecuteGitAllowError ¶
func (env *GitTestEnv) ExecuteGitAllowError(args ...string) (string, error)
ExecuteGitAllowError runs a git command but doesn't fail the test if it returns an error
func (*GitTestEnv) ExecuteGitflow ¶
func (env *GitTestEnv) ExecuteGitflow(args ...string) string
ExecuteGitflow calls the Gitflow functionality directly via the Go API
type SetupTestEnvOption ¶
type SetupTestEnvOption func(*testEnvOptions)
SetupTestEnvOption configures options for SetupTestEnv