Documentation
¶
Overview ¶
Package ghfake is an in-memory implementation of the ghclient store interfaces for controller tests: deterministic, mutation-recording, and just faithful enough (label filters, search-by-label queries) to exercise the controllers' GitHub interactions without a server.
Index ¶
- type Store
- func (s *Store) AddLabels(_ context.Context, _ ghclient.Repo, number int, add []string) error
- func (s *Store) Assign(_ context.Context, _ ghclient.Repo, number int, logins []string) error
- func (s *Store) Close(_ context.Context, _ ghclient.Repo, number int) error
- func (s *Store) Comment(_ context.Context, _ ghclient.Repo, number int, body string) error
- func (s *Store) Create(_ context.Context, repo ghclient.Repo, req ghclient.IssueRequest) (*ghclient.Issue, error)
- func (s *Store) EditBody(_ context.Context, _ ghclient.Repo, number int, body string) error
- func (s *Store) ListComments(_ context.Context, _ ghclient.Repo, number int) ([]*ghclient.Comment, error)
- func (s *Store) ListOpen(_ context.Context, repo ghclient.Repo, labels []string) ([]*ghclient.Issue, error)
- func (s *Store) RemoveLabel(_ context.Context, _ ghclient.Repo, number int, name string) error
- func (s *Store) SearchIssues(_ context.Context, query string) ([]*ghclient.Issue, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store struct {
Mu sync.Mutex
// Issues by number.
Issues map[int]*ghclient.Issue
// Comments by issue number, in posting order.
Comments map[int][]string
// Closed issue numbers, in closing order.
Closed []int
// Assigned logins by issue number.
Assigned map[int][]string
// Now stamps CreatedAt on created issues.
Now func() time.Time
// contains filtered or unexported fields
}
Store is the in-memory fake. Fields are exported for test assertions; take Mu when reading them from concurrent tests.
func (*Store) Create ¶
func (s *Store) Create(_ context.Context, repo ghclient.Repo, req ghclient.IssueRequest) (*ghclient.Issue, error)
Create implements ghclient.IssueStore.
func (*Store) ListComments ¶
func (s *Store) ListComments(_ context.Context, _ ghclient.Repo, number int) ([]*ghclient.Comment, error)
ListComments implements ghclient.IssueStore.
func (*Store) ListOpen ¶
func (s *Store) ListOpen(_ context.Context, repo ghclient.Repo, labels []string) ([]*ghclient.Issue, error)
ListOpen implements ghclient.IssueStore.
func (*Store) RemoveLabel ¶
RemoveLabel implements ghclient.IssueStore; removing an absent label is not an error, matching the real client.