Documentation
¶
Overview ¶
Package ghtest provides tools to test code that interacts with GitHub.
Index ¶
- type MergePullRequest
- type ShamHub
- func (sh *ShamHub) APIURL() string
- func (sh *ShamHub) Close() error
- func (sh *ShamHub) GitRoot() string
- func (sh *ShamHub) GitURL() string
- func (sh *ShamHub) ListPulls() ([]*github.PullRequest, error)
- func (sh *ShamHub) MergePull(req MergePullRequest) error
- func (sh *ShamHub) NewRepository(owner, repo string) (string, error)
- func (sh *ShamHub) RepoURL(owner, repo string) string
- type ShamHubConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MergePullRequest ¶
type MergePullRequest struct {
Owner, Repo string
Number int
// Optional fields:
Time time.Time
CommitterName, CommitterEmail string
}
MergePullRequest is a request to merge a PR.
type ShamHub ¶
type ShamHub struct {
// contains filtered or unexported fields
}
ShamHub is a fake GitHub server.
It can be used to test code that interacts with GitHub without actually making requests to the GitHub API. It provides a Git HTTP remote, and a GitHub API server.
For the Git HTTP remote functionality, it relies on the 'git http-backend' command included with Git.
func NewShamHub ¶
func NewShamHub(cfg ShamHubConfig) (*ShamHub, error)
NewShamHub creates a new ShamHub server. The server should be closed with the Close method when done.
func (*ShamHub) APIURL ¶
APIURL returns the URL to which API requests should be sent. Configure the GitHub client to use this URL.
func (*ShamHub) GitURL ¶
GitURL returns the URL for the Git HTTP server. Append <owner>/<repo>.git to these to get the Git remote.
func (*ShamHub) ListPulls ¶
func (sh *ShamHub) ListPulls() ([]*github.PullRequest, error)
ListPulls returns a list of all pull requests that have been created on the ShamHub and their current state.
func (*ShamHub) MergePull ¶
func (sh *ShamHub) MergePull(req MergePullRequest) error
MergePull merges the pull request with the given owner, repo, and number.
func (*ShamHub) NewRepository ¶
NewRepository creates a new Git repository with the given owner and repo name and returns the URL to the repository.
type ShamHubConfig ¶
type ShamHubConfig struct { // Git is the path to the git binary. // If not set, we'll look for it in the PATH. Git string Log *log.Logger }
ShamHubConfig configures a ShamHub server.