ghtest

package
v0.1.0-alpha4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 24, 2024 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package ghtest provides tools to test code that interacts with GitHub.

Index

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

func (sh *ShamHub) APIURL() string

APIURL returns the URL to which API requests should be sent. Configure the GitHub client to use this URL.

func (*ShamHub) Close

func (sh *ShamHub) Close() error

Close closes the ShamHub.

func (*ShamHub) GitRoot

func (sh *ShamHub) GitRoot() string

GitRoot returns the path to the root directory of the Git repositories.

func (*ShamHub) GitURL

func (sh *ShamHub) GitURL() string

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

func (sh *ShamHub) NewRepository(owner, repo string) (string, error)

NewRepository creates a new Git repository with the given owner and repo name and returns the URL to the repository.

func (*ShamHub) RepoURL

func (sh *ShamHub) RepoURL(owner, repo string) string

RepoURL returns the URL for the Git repository with the given owner and repo name.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL