Documentation
¶
Overview ¶
Package gitlabtest is a fake GitLab for tests of code that reaches GitLab through internal/gitlab. It serves the merge request, project and branch endpoints AppTown uses, keeps each merge request's state and the descriptions written to it, and records the merges asked of it. What a merge does to Git is the test's business: it supplies OnMerge.
Index ¶
- Constants
- type Merge
- type Refusal
- type Server
- func (s *Server) Client() (*gitlab.Client, error)
- func (s *Server) Descriptions(project string, iid int) []string
- func (s *Server) Merges() []Merge
- func (s *Server) Put(project string, mr gitlab.MergeRequest)
- func (s *Server) RefuseDescriptions(r *Refusal)
- func (s *Server) Request(project string, iid int) (gitlab.MergeRequest, bool)
- func (s *Server) Settings(settings gitlab.MergeSettings)
- func (s *Server) Update(project string, iid int, change func(*gitlab.MergeRequest))
Constants ¶
const Token = "test-token"
Token is the only token the fake accepts.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Merge ¶
type Merge struct {
Project string
IID int
SHA string
Message string
Squash bool
Settings gitlab.MergeSettings
}
Merge is one merge call as the fake received it, with the project settings in force when it arrived.
type Server ¶
type Server struct {
URL string
// OnRead refreshes a merge request before it is served (a head that
// follows a real remote, say).
OnRead func(project string, mr *gitlab.MergeRequest)
// OnMerge performs a merge. A nil error marks the request merged; a
// *Refusal is answered as GitLab would, any other error as a 500.
OnMerge func(m Merge, mr *gitlab.MergeRequest) error
// OnBranch answers a branch's head commit.
OnBranch func(project, branch string) (string, error)
// contains filtered or unexported fields
}
Server is the fake. Its hooks run with its lock held, so they may change the merge request they are handed but must not call the server.
func New ¶
New starts a fake GitLab that closes when the test ends. Its projects merge fast-forward, never squash and do not rebase automatically until told otherwise.
func (*Server) Descriptions ¶
Descriptions are the descriptions a merge request was given, oldest first: the one it was opened with, then each replacement.
func (*Server) Put ¶
func (s *Server) Put(project string, mr gitlab.MergeRequest)
Put records a merge request as GitLab holds it.
func (*Server) RefuseDescriptions ¶
RefuseDescriptions makes every description update fail with r; nil accepts them again.
func (*Server) Settings ¶
func (s *Server) Settings(settings gitlab.MergeSettings)
Settings sets how every project merges, as GitLab reports it.