Documentation
¶
Overview ¶
Package githubtest provides an in-process fake of the GitHub REST endpoints Octomaton uses, for tests. It verifies App JWTs and installation tokens and records everything it is asked to do.
Index ¶
- func Key() *rsa.PrivateKey
- type CheckRun
- type IssueComment
- type PullRequest
- type Reaction
- type Repository
- type Server
- func (s *Server) AddCheckRun(cr CheckRun) int64
- func (s *Server) AddFile(repo, ref, path, content string)
- func (s *Server) AddInstallation(id int64, account string, repos ...Repository)
- func (s *Server) CheckRun(id int64) (CheckRun, bool)
- func (s *Server) CheckRuns() []CheckRun
- func (s *Server) Comments() []IssueComment
- func (s *Server) Reactions() []Reaction
- func (s *Server) Requests() []string
- func (s *Server) SetBranch(repo, branch, sha string)
- func (s *Server) SetComparison(repo, base, head string, files []string)
- func (s *Server) SetFailFiles(fail bool)
- func (s *Server) SetFailTokens(fail func(TokenRequest) bool)
- func (s *Server) SetPermission(repo, login, level string)
- func (s *Server) SetPullRequest(repo string, pr PullRequest)
- func (s *Server) SetPullRequestFiles(repo string, number int, files []string)
- func (s *Server) SuiteID(repo, sha string) int64
- func (s *Server) TokenRequests() []TokenRequest
- type TokenRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CheckRun ¶
type CheckRun struct {
ID int64
SuiteID int64
Repo string
Name string
HeadSHA string
Status string
Conclusion string
ExternalID string
DetailsURL string
Title string
Summary string
Text string
StartedAt string
CompletedAt string
Actions []map[string]any
// Updates counts PATCH requests received for this check run.
Updates int
}
CheckRun is a check run stored by the fake.
type IssueComment ¶
IssueComment records a comment posted on an issue or pull request.
type PullRequest ¶
type PullRequest struct {
Number int
State string
Draft bool
HeadRef string
HeadSHA string
HeadRepo string
BaseRef string
BaseSHA string
Author string
AuthorAssociation string
}
PullRequest is a pull request served by the fake.
type Repository ¶
Repository is an installation repository served by the fake.
type Server ¶
type Server struct {
*httptest.Server
AppID int64
// Files maps "owner/repo@ref:path" to file content.
Files map[string]string
// PullRequestFiles maps "owner/repo#number" to changed file names.
PullRequestFiles map[string][]string
// Comparisons maps "owner/repo:base...head" to changed file names.
Comparisons map[string][]string
// Permissions maps "owner/repo:login" to a permission level.
Permissions map[string]string
// TeamMembers maps "org/team-slug" to the logins of its active members.
TeamMembers map[string][]string
// contains filtered or unexported fields
}
Server is a fake GitHub API.
func (*Server) AddCheckRun ¶
AddCheckRun stores an existing check run and returns its ID.
func (*Server) AddInstallation ¶
func (s *Server) AddInstallation(id int64, account string, repos ...Repository)
AddInstallation registers an installation of the App on an account with its repositories.
func (*Server) Comments ¶
func (s *Server) Comments() []IssueComment
Comments returns the comments posted.
func (*Server) SetComparison ¶
SetComparison sets the files changed between base and head.
func (*Server) SetFailFiles ¶
SetFailFiles makes content requests fail with HTTP 500.
func (*Server) SetFailTokens ¶
func (s *Server) SetFailTokens(fail func(TokenRequest) bool)
SetFailTokens makes token requests for which fail returns true fail with HTTP 422.
func (*Server) SetPermission ¶
SetPermission sets login's permission level on repo.
func (*Server) SetPullRequest ¶
func (s *Server) SetPullRequest(repo string, pr PullRequest)
SetPullRequest stores a pull request of repo.
func (*Server) SetPullRequestFiles ¶
SetPullRequestFiles sets the files changed by a pull request.
func (*Server) TokenRequests ¶
func (s *Server) TokenRequests() []TokenRequest
TokenRequests returns the installation token requests received.