Documentation ¶
Index ¶
- Variables
- func CopyDirectory(src, dst string) error
- func RenderTable(table *gherkin.DataTable) string
- type Commit
- type CommitTableBuilder
- type DataTable
- type ExecutedGitCommand
- type GitEnvironment
- type GitManager
- type GitRepository
- func (repo *GitRepository) Branches() (result []string, err error)
- func (repo *GitRepository) CheckoutBranch(name string) error
- func (repo *GitRepository) Commits(fields []string) (result []Commit, err error)
- func (repo *GitRepository) Configuration() *git.Configuration
- func (repo *GitRepository) CreateBranch(name string) error
- func (repo *GitRepository) CreateCommit(commit Commit) error
- func (repo *GitRepository) CreateFeatureBranch(name string) error
- func (repo *GitRepository) CreateFile(name, content string) error
- func (repo *GitRepository) CreatePerennialBranches(names ...string) error
- func (repo *GitRepository) CurrentBranch() (result string, err error)
- func (repo *GitRepository) FileContentInCommit(sha string, filename string) (result string, err error)
- func (repo *GitRepository) FilesInCommit(sha string) (result []string, err error)
- func (repo *GitRepository) HasFile(name, content string) (result bool, err error)
- func (repo *GitRepository) PushBranch(name string) error
- func (repo *GitRepository) RegisterOriginalCommit(commit Commit)
- func (repo *GitRepository) SetOffline(enabled bool) error
- func (repo *GitRepository) SetRemote(target string) error
- type ShellRunner
- func (runner *ShellRunner) AddTempShellOverride(name, content string) error
- func (runner *ShellRunner) RemoveTempShellOverrides()
- func (runner *ShellRunner) Run(name string, arguments ...string) (output string, err error)
- func (runner *ShellRunner) RunMany(commands [][]string) error
- func (runner *ShellRunner) RunString(command string) (output string, err error)
Constants ¶
This section is empty.
Variables ¶
var Debug = false
Debug indicates whether test code should log output of console commands
Functions ¶
func CopyDirectory ¶
CopyDirectory copies all files in the given src directory into the given dst directory. Both the source and the destination directory must exist.
func RenderTable ¶
RenderTable provides the textual Gherkin representation of the given Gherkin table.
Types ¶
type Commit ¶
type Commit struct { Author string Branch string FileContent string FileName string Locations []string Message string SHA string }
Commit describes a Git commit.
func DefaultCommit ¶
func DefaultCommit() Commit
DefaultCommit provides a new Commit instance populated with the default values used in the absence of value specified by the test.
type CommitTableBuilder ¶
type CommitTableBuilder struct {
// contains filtered or unexported fields
}
CommitTableBuilder collects data about commits in Git repositories in the same way that our Gherkin tables describing commits in repos are organized.
func NewCommitTableBuilder ¶
func NewCommitTableBuilder() CommitTableBuilder
NewCommitTableBuilder provides a fully initialized instance of CommitTableBuilder.
func (*CommitTableBuilder) Add ¶
func (builder *CommitTableBuilder) Add(commit Commit, location string)
Add registers the given commit from the given location into this table.
func (*CommitTableBuilder) Table ¶
func (builder *CommitTableBuilder) Table(fields []string) (result DataTable)
Table provides the data accumulated by this CommitTableBuilder as a DataTable.
type DataTable ¶
type DataTable struct {
// contains filtered or unexported fields
}
DataTable allows comparing user-generated data with Gherkin tables.
func FromGherkin ¶
FromGherkin provides a DataTable instance populated with data from the given Gherkin table.
func RenderExecutedGitCommands ¶
func RenderExecutedGitCommands(commands []ExecutedGitCommand, table *gherkin.DataTable) DataTable
RenderExecutedGitCommands provides the textual Gherkin table representation of the given executed Git commands. The DataTable table matches the structure of the given Gherkin table.
type ExecutedGitCommand ¶
type ExecutedGitCommand struct { // Branch contains the branch in which this command ran. Branch string // Command contains the command executed. Command string }
ExecutedGitCommand describes a Git command that was executed by Git Town during testing.
func GitCommandsInGitTownOutput ¶
func GitCommandsInGitTownOutput(output string) (result []ExecutedGitCommand)
GitCommandsInGitTownOutput provides the Git commands mentioned in the given Git Town output.
type GitEnvironment ¶
type GitEnvironment struct { // Dir is the directory that this environment is in. Dir string // OriginRepo is the Git repository that simulates the remote repo (on GitHub). OriginRepo GitRepository // DeveloperRepo is the Git repository that is locally checked out at the developer machine. DeveloperRepo GitRepository }
GitEnvironment is the complete Git environment for a test scenario.
func CloneGitEnvironment ¶
func CloneGitEnvironment(original *GitEnvironment, dir string) (*GitEnvironment, error)
CloneGitEnvironment provides a GitEnvironment instance in the given directory, containing a copy of the given GitEnvironment.
func NewStandardGitEnvironment ¶
func NewStandardGitEnvironment(dir string) (gitEnv *GitEnvironment, err error)
NewStandardGitEnvironment provides a GitEnvironment in the given directory, fully populated as a standardized setup for scenarios.
func (GitEnvironment) CommitTable ¶
func (env GitEnvironment) CommitTable(fields []string) (result DataTable, err error)
CommitTable provides a table for all commits in this Git environment containing only the given fields.
func (*GitEnvironment) CreateCommits ¶
func (env *GitEnvironment) CreateCommits(table *gherkin.DataTable) error
CreateCommits creates the commits described by the given Gherkin table in this Git repository.
func (GitEnvironment) Remove ¶
func (env GitEnvironment) Remove() error
Remove deletes all files used by this GitEnvironment from disk.
type GitManager ¶
type GitManager struct {
// contains filtered or unexported fields
}
GitManager manages the Git setup for the entire test suite. In particular, it creates the Git setup for individual feature specs (GitEnvironment).
func NewGitManager ¶
func NewGitManager(baseDir string) *GitManager
NewGitManager provides a new GitManager instance operating in the given directory.
func (*GitManager) CreateMemoizedEnvironment ¶
func (manager *GitManager) CreateMemoizedEnvironment() error
CreateMemoizedEnvironment creates the Git environment cache that makes cloning new GitEnvironment instances faster.
func (*GitManager) CreateScenarioEnvironment ¶
func (manager *GitManager) CreateScenarioEnvironment(scenarioName string) (*GitEnvironment, error)
CreateScenarioEnvironment provides a new GitEnvironment for the scenario with the given name
type GitRepository ¶
type GitRepository struct { // Dir contains the path of the directory that this repository is in. Dir string // ShellRunner enables to run console commands in this repo. ShellRunner // contains filtered or unexported fields }
GitRepository is a Git repository that exists inside a Git environment.
func CloneGitRepository ¶
func CloneGitRepository(originDir, workingDir, homeDir string) (GitRepository, error)
CloneGitRepository clones the given parent repo into a new GitRepository.
func InitGitRepository ¶
func InitGitRepository(workingDir string, homeDir string) (GitRepository, error)
InitGitRepository initializes a fully functioning Git repository in the given path, including necessary Git configuration. Creates missing folders as needed.
func NewGitRepository ¶
func NewGitRepository(workingDir string, homeDir string) GitRepository
NewGitRepository provides a new GitRepository instance working in the given directory. The directory must contain an existing Git repo.
func (*GitRepository) Branches ¶
func (repo *GitRepository) Branches() (result []string, err error)
Branches provides the names of the local branches in this Git repository, sorted alphabetically.
func (*GitRepository) CheckoutBranch ¶
func (repo *GitRepository) CheckoutBranch(name string) error
CheckoutBranch checks out the Git branch with the given name in this repo.
func (*GitRepository) Commits ¶
func (repo *GitRepository) Commits(fields []string) (result []Commit, err error)
Commits provides a tabular list of the commits in this Git repository with the given fields.
func (*GitRepository) Configuration ¶
func (repo *GitRepository) Configuration() *git.Configuration
Configuration lazy-loads the Git-Town configuration for this repo.
func (*GitRepository) CreateBranch ¶
func (repo *GitRepository) CreateBranch(name string) error
CreateBranch creates a new branch with the given name. The created branch is a normal branch. To create feature branches, use CreateFeatureBranch.
func (*GitRepository) CreateCommit ¶
func (repo *GitRepository) CreateCommit(commit Commit) error
CreateCommit creates a commit with the given properties in this Git repo.
func (*GitRepository) CreateFeatureBranch ¶
func (repo *GitRepository) CreateFeatureBranch(name string) error
CreateFeatureBranch creates a branch with the given name in this repository.
func (*GitRepository) CreateFile ¶
func (repo *GitRepository) CreateFile(name, content string) error
CreateFile creates a file with the given name and content in this repository.
func (*GitRepository) CreatePerennialBranches ¶
func (repo *GitRepository) CreatePerennialBranches(names ...string) error
CreatePerennialBranches creates perennial branches with the given names in this repository.
func (*GitRepository) CurrentBranch ¶
func (repo *GitRepository) CurrentBranch() (result string, err error)
CurrentBranch provides the currently checked out branch for this repo.
func (*GitRepository) FileContentInCommit ¶
func (repo *GitRepository) FileContentInCommit(sha string, filename string) (result string, err error)
FileContentInCommit provides the content of the file with the given name in the commit with the given SHA.
func (*GitRepository) FilesInCommit ¶
func (repo *GitRepository) FilesInCommit(sha string) (result []string, err error)
FilesInCommit provides the names of the files that the commit with the given SHA changes.
func (*GitRepository) HasFile ¶
func (repo *GitRepository) HasFile(name, content string) (result bool, err error)
HasFile indicates whether this repository contains a file with the given name and content.
func (*GitRepository) PushBranch ¶
func (repo *GitRepository) PushBranch(name string) error
PushBranch pushes the branch with the given name to the remote.
func (*GitRepository) RegisterOriginalCommit ¶
func (repo *GitRepository) RegisterOriginalCommit(commit Commit)
RegisterOriginalCommit tracks the given commit as existing in this repo before the system under test executed.
func (*GitRepository) SetOffline ¶
func (repo *GitRepository) SetOffline(enabled bool) error
SetOffline enables or disables offline mode for this GitRepository.
func (*GitRepository) SetRemote ¶
func (repo *GitRepository) SetRemote(target string) error
SetRemote sets the remote of this Git repository to the given target.
type ShellRunner ¶
type ShellRunner struct {
// contains filtered or unexported fields
}
ShellRunner runs shell commands in the given directory, using a customizable environment. Possible customizations:
- Temporarily override certain shell commands with mock implementations. Temporary mocks are only valid for the next command being run.
func NewShellRunner ¶
func NewShellRunner(workingDir string, homeDir string) ShellRunner
NewShellRunner provides a new ShellRunner instance that executes in the given directory.
func (*ShellRunner) AddTempShellOverride ¶
func (runner *ShellRunner) AddTempShellOverride(name, content string) error
AddTempShellOverride temporarily mocks the shell command with the given name with the given Bash script.
func (*ShellRunner) RemoveTempShellOverrides ¶
func (runner *ShellRunner) RemoveTempShellOverrides()
RemoveTempShellOverrides removes all custom shell overrides.
func (*ShellRunner) Run ¶
func (runner *ShellRunner) Run(name string, arguments ...string) (output string, err error)
Run runs the given command with the given arguments in this ShellRunner's directory. Shell overrides will be used and removed when done.
func (*ShellRunner) RunMany ¶
func (runner *ShellRunner) RunMany(commands [][]string) error
RunMany runs all given commands in current directory. Commands are provided as a list of argv-style strings. Shell overrides apply for the first command only. Failed commands abort immediately with the encountered error.
func (*ShellRunner) RunString ¶
func (runner *ShellRunner) RunString(command string) (output string, err error)
RunString runs the given command (including possible arguments) in this ShellRunner's directory. Shell overrides will be used and removed when done.
The current implementation splits the string by space and therefore only works for simple commands without quoted arguments.