Documentation
¶
Overview ¶
Package githubfake is one GitHub organisation, in memory, answering the calls the controller makes and changing as they change it.
For tests only. It is a package rather than a test file because two packages test against it: the GitHub client, and the controller that drives it end to end.
Index ¶
- Constants
- type Account
- type App
- type Budget
- type FailedInvitation
- type Installation
- type Invitation
- type Member
- type Org
- func (o *Org) Accept(email, login string, verified bool)
- func (o *Org) AcceptAccount(login string)
- func (o *Org) AddAccount(login string, emails ...string) *Account
- func (o *Org) AddMember(login string, owner bool, emails ...string)
- func (o *Org) AddTeam(slug string, members ...string)
- func (o *Org) Authorize(login string) string
- func (o *Org) Client() *http.Client
- func (o *Org) Did() []string
- func (o *Org) Hit(key string) int
- func (o *Org) Join(login string)
- func (o *Org) Revoke(login string)
- func (o *Org) SetEmail(login, email string, verified, remove bool)
- type Rejection
- type Team
- type TokenRequest
Constants ¶
const ( ClientID = "Iv1.link" ClientSecret = "link-secret" )
ClientID and ClientSecret are the link App's, as the fake knows them.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct {
ID int64
Login string
// Emails are the account's addresses, to whether GitHub verified each.
Emails map[string]bool
// Access and Refresh are the pair currently valid, empty when none is.
Access, Refresh string
// contains filtered or unexported fields
}
Account is one GitHub account a person can authorize the link App as.
type FailedInvitation ¶
FailedInvitation is an invitation that expired.
type Installation ¶
type Installation struct {
Account string
Permissions map[string]string
RepositorySelection string
}
Installation is one installation of the App: the permissions its owner accepted, which lag the App's until they approve a request.
type Invitation ¶
type Invitation struct {
ID int64
Email string
// Login is set for an invitation to an account rather than an address.
Login string
Teams []int64
}
Invitation is a pending invitation.
type Org ¶
type Org struct {
Login string
// Members by login.
Members map[string]*Member
// Teams by slug.
Teams map[string]*Team
// Invitations by address.
Invitations map[string]*Invitation
// Token is the installation token every call must carry.
Token string
// Actions is every change made, in order, as "verb target".
Actions []string
// Refuse makes the next matching write fail, keyed by the action text.
Refuse map[string]string
// GraphQLError, when set, is returned inside a 200 from the members
// query, as GitHub does.
GraphQLError string
// Budget, when set, is what the members query reports as its
// `rateLimit`, so a test can ask for a wait before the next page.
Budget *Budget
// Rejections are answers served before any handler, in order, each
// once: a rate limit as GitHub sends it. Hits counts every request by
// "METHOD path", rejected ones included.
Rejections []Rejection
Hits map[string]int
// Accounts are the GitHub accounts people link, by login, whether or
// not they are members.
Accounts map[string]*Account
// UsersDown makes every call made with a person's token fail with a
// 502, as an outage would.
UsersDown bool
// Seats and Filled are the plan; Seats zero is a plan the App may not
// read, as without organisation administration.
Seats, Filled int
// Failed are failed invitations.
Failed []FailedInvitation
// Collaborators are outside collaborators, by login.
Collaborators []string
// Public are the addresses accounts show on their profiles, by login.
Public map[string]string
// App is what GET /app answers, asked as the App.
App App
// Installations are the App's installations, by id.
Installations map[int64]*Installation
// AppReads counts the calls made as the App to read it or one of its
// installations.
AppReads int
// TokenRequests are the installation tokens asked for, in order, with
// the narrowing each asked for.
TokenRequests []TokenRequest
// Uninstalled are installation ids GitHub no longer knows: minting a
// token for one is a 404.
Uninstalled map[int64]bool
// Repositories are the repositories every installation can reach.
// Empty reaches any; otherwise a token narrowed to another is a 422,
// as GitHub answers.
Repositories []string
// contains filtered or unexported fields
}
Org is the organisation's state.
func Start ¶
Start serves the organisation and points the GitHub client at it for the test's duration. Tests using it must not run in parallel with each other: the client's base URL is shared.
func (*Org) Accept ¶
Accept has somebody accept their invitation with an account: they become a member, in the invitation's teams.
func (*Org) AcceptAccount ¶
AcceptAccount has a linked account accept its invitation: it becomes a member, in the invitation's teams.
func (*Org) AddAccount ¶
AddAccount creates a GitHub account with verified addresses; an address ending in "?" is on the account and unverified.
func (*Org) AddTeam ¶
AddTeam creates a team with members; maintainers are marked with a trailing "*".
func (*Org) Authorize ¶
Authorize has the account authorize the link App, and returns the code its callback would carry.
type Rejection ¶
type Rejection struct {
// Path is the request path it answers, e.g. "/graphql".
Path string
Status int
Header map[string]string
Body string
}
Rejection is one canned answer to the next request for a path.
type TokenRequest ¶
type TokenRequest struct {
Installation int64
// Body is the narrowing as sent, nil when the request had no body.
Body *githubapp.Narrowing
}
TokenRequest is one installation token asked for.