Documentation
¶
Overview ¶
Package githubpagestest is an in-process fake of the slice of the GitHub REST API the github-pages hosting adapter calls, for tests only. The adapter speaks through the forge the way the site setup's forge stage does — `gh api` as the person who invoked the verb, never a token abcd holds — so the fake answers the adapter's API calls directly rather than over a socket, and fails them the way `gh api` does: an error naming the HTTP status.
It answers exactly these routes, and anything else is a 404:
GET repos/{owner}/{repo} the repository: private, has_pages
GET repos/{owner}/{repo}/pages the Pages site: build_type, cname, html_url
POST repos/{owner}/{repo}/pages create the Pages site
PUT repos/{owner}/{repo}/pages change its source or custom domain
Index ¶
Constants ¶
const ( GetRepo = "GET repo" GetPages = "GET pages" CreatePages = "POST pages" UpdatePages = "PUT pages" )
Route keys name a route for Fail and for the call log.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pages ¶
type Pages struct {
BuildType string
CNAME string
// HTMLURL, when set, is the address the site reports in place of the one
// GitHub would derive from its domain or its repository.
HTMLURL string
}
Pages is one repository's Pages site.
type Repo ¶
type Repo struct {
Private bool
// Pages is nil while the repository has no Pages site.
Pages *Pages
}
Repo is one repository the fake holds.
type Server ¶
type Server struct {
Mu sync.Mutex
Repos map[string]*Repo
// Fail makes a route answer with this error.
Fail map[string]error
// Calls logs each call as "<route key> <body>".
Calls []string
}
Server is the fake. Its fields are the forge's state; lock Mu to read them while a call may be in flight.
func New ¶
func New() *Server
New is a fake holding one public repository, acme/widgets, with no Pages site yet.