Documentation ¶
Overview ¶
Package repoharness contains code for a test harness that allows for easy faking of a repo checkout.
Index ¶
- Variables
- type Config
- type File
- type RemoteProject
- type RepoHarness
- func (r *RepoHarness) AddFile(project RemoteProject, branch string, file File) (string, error)
- func (r *RepoHarness) AddFiles(project RemoteProject, branch string, files []File) (string, error)
- func (r *RepoHarness) AssertNoRemoteDiff() error
- func (r *RepoHarness) AssertProjectBranchEqual(project RemoteProject, branch, snapshotPath string) error
- func (r *RepoHarness) AssertProjectBranchHasAncestor(project RemoteProject, branch, snapshotPath, snapshotBranch string) error
- func (r *RepoHarness) AssertProjectBranches(project RemoteProject, branches []string) error
- func (r *RepoHarness) AssertProjectBranchesExact(project RemoteProject, branches []string) error
- func (r *RepoHarness) AssertProjectBranchesMissing(project RemoteProject, branches []string) error
- func (r *RepoHarness) Checkout(manifestProject RemoteProject, branch, manifestFile string) (string, error)
- func (r *RepoHarness) CreateRemoteRef(project RemoteProject, ref string, commit string) error
- func (r *RepoHarness) CreateRemoteRefForce(project RemoteProject, ref string, commit string) error
- func (r *RepoHarness) GetRecentRemoteSnapshot(remote string) (string, error)
- func (r *RepoHarness) GetRemotePath(project RemoteProject) string
- func (r *RepoHarness) HarnessRoot() string
- func (r *RepoHarness) Initialize(config *Config) error
- func (r *RepoHarness) Manifest() repo.Manifest
- func (r *RepoHarness) ProcessSubmitRefs() error
- func (r *RepoHarness) ReadFile(project RemoteProject, branch, filePath string) ([]byte, error)
- func (r *RepoHarness) Snapshot(path string) (string, error)
- func (r *RepoHarness) SnapshotRemotes() error
- func (r *RepoHarness) Teardown() error
Constants ¶
This section is empty.
Variables ¶
var ( // CommandRunnerImpl is the command runner impl currently being used by the // package. Exists for testing purposes. CommandRunnerImpl cmd.CommandRunner = cmd.RealCommandRunner{} // ForSubmitRefRegexp matches refs of the form refs/for/...%submit ForSubmitRefRegexp = regexp.MustCompile(`^refs\/for\/(?P<name>.+)%submit$`) )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Initialize() will create a test harness with // the appropriate remote repos and a local repo. // Both remote and local repos will have the appropriate // projects created (with initialized git repos inside them). Manifest repo.Manifest }
Config for a RepoHarness.
type RemoteProject ¶
RemoteProject identifies a remote project.
func GetRemoteProject ¶
func GetRemoteProject(project repo.Project) RemoteProject
GetRemoteProject returns the corresponding remote project for a given project.
type RepoHarness ¶
type RepoHarness struct {
// contains filtered or unexported fields
}
RepoHarness is a test harness that fakes out an entire repo checkout based on a supplied manifest.
func (*RepoHarness) AddFile ¶
func (r *RepoHarness) AddFile(project RemoteProject, branch string, file File) (string, error)
AddFile adds a file to the specified branch in the specified remote project. Returns the sha1 of the commit that adds the file.
func (*RepoHarness) AddFiles ¶
func (r *RepoHarness) AddFiles(project RemoteProject, branch string, files []File) (string, error)
AddFiles adds files to the specified branch in the specified remote project. Returns a map with the sha1's of the commits.
func (*RepoHarness) AssertNoRemoteDiff ¶
func (r *RepoHarness) AssertNoRemoteDiff() error
func (*RepoHarness) AssertProjectBranchEqual ¶
func (r *RepoHarness) AssertProjectBranchEqual(project RemoteProject, branch, snapshotPath string) error
AssertProjectBranchEqual asserts that the specified branch in the project matches the corresponding branch in the given snapshot.
func (*RepoHarness) AssertProjectBranchHasAncestor ¶
func (r *RepoHarness) AssertProjectBranchHasAncestor(project RemoteProject, branch, snapshotPath, snapshotBranch string) error
AssertProjectBranchHasAncestor asserts that the specified branch in the project descends from the given snapshot.
func (*RepoHarness) AssertProjectBranches ¶
func (r *RepoHarness) AssertProjectBranches(project RemoteProject, branches []string) error
AssertProjectBranches asserts that the remote project has the correct branches.
func (*RepoHarness) AssertProjectBranchesExact ¶
func (r *RepoHarness) AssertProjectBranchesExact(project RemoteProject, branches []string) error
AssertProjectBranchesExact asserts that the remote project has only the correct branches.
func (*RepoHarness) AssertProjectBranchesMissing ¶
func (r *RepoHarness) AssertProjectBranchesMissing(project RemoteProject, branches []string) error
AssertProjectBranchesMissing asserts that the remote project does not have the specified branches.
func (*RepoHarness) Checkout ¶
func (r *RepoHarness) Checkout(manifestProject RemoteProject, branch, manifestFile string) (string, error)
Checkout creates a local checkout of the project using the specified manifest project/branch/file, if one does not already exist. Returns a path to the local checkout, and a potential error.
func (*RepoHarness) CreateRemoteRef ¶
func (r *RepoHarness) CreateRemoteRef(project RemoteProject, ref string, commit string) error
CreateRemoteRef creates a remote ref for a specific project. Otherwise, a temporary local checkout will be created and an empty commit will be used to create the remote ref.
func (*RepoHarness) CreateRemoteRefForce ¶
func (r *RepoHarness) CreateRemoteRefForce(project RemoteProject, ref string, commit string) error
func (*RepoHarness) GetRecentRemoteSnapshot ¶
func (r *RepoHarness) GetRecentRemoteSnapshot(remote string) (string, error)
GetRecentRemoteSnapshot returns the path of the most recent snapshot for a particular remote.
func (*RepoHarness) GetRemotePath ¶
func (r *RepoHarness) GetRemotePath(project RemoteProject) string
GetRemotePath returns the path to the remote project repo.
func (*RepoHarness) HarnessRoot ¶
func (r *RepoHarness) HarnessRoot() string
HarnessRoot returns the path to the root directory of the test harness.
func (*RepoHarness) Initialize ¶
func (r *RepoHarness) Initialize(config *Config) error
Initialize creates a RepoHarness based on the given config.
func (*RepoHarness) Manifest ¶
func (r *RepoHarness) Manifest() repo.Manifest
Manifest returns the manifest associated with the harness.
func (*RepoHarness) ProcessSubmitRefs ¶
func (r *RepoHarness) ProcessSubmitRefs() error
ProcessSubmitRefs makes sure that refs/heads/... refs accurately reflect corresponding refs/for/...%submit refs, if they exist.
func (*RepoHarness) ReadFile ¶
func (r *RepoHarness) ReadFile(project RemoteProject, branch, filePath string) ([]byte, error)
ReadFile reads a file from a remote.
func (*RepoHarness) Snapshot ¶
func (r *RepoHarness) Snapshot(path string) (string, error)
Snapshot recursively copies a directory's contents to a temp dir.
func (*RepoHarness) SnapshotRemotes ¶
func (r *RepoHarness) SnapshotRemotes() error
SnapshotRemotes takes a snapshot of the current state of each remote and stores them within the harness struct.
func (*RepoHarness) Teardown ¶
func (r *RepoHarness) Teardown() error
Teardown tears down a repo harness.