Documentation
¶
Index ¶
- func NewFixtureClient() ghclient.Client
- func SeedRoborevDB(path string) error
- type DiffRepoResult
- type FixtureClient
- func (c *FixtureClient) ApproveWorkflowRun(_ context.Context, _, _ string, _ int64) error
- func (c *FixtureClient) CreateIssueComment(_ context.Context, owner, repo string, number int, body string) (*gh.IssueComment, error)
- func (c *FixtureClient) CreateReview(_ context.Context, _, _ string, _ int, _, _ string) (*gh.PullRequestReview, error)
- func (c *FixtureClient) EditIssue(_ context.Context, owner, repo string, number int, state string) (*gh.Issue, error)
- func (c *FixtureClient) EditPullRequest(_ context.Context, owner, repo string, number int, ...) (*gh.PullRequest, error)
- func (c *FixtureClient) GetCombinedStatus(_ context.Context, owner, repo, ref string) (*gh.CombinedStatus, error)
- func (c *FixtureClient) GetIssue(_ context.Context, owner, repo string, number int) (*gh.Issue, error)
- func (c *FixtureClient) GetPullRequest(_ context.Context, owner, repo string, number int) (*gh.PullRequest, error)
- func (c *FixtureClient) GetRepository(_ context.Context, owner, repo string) (*gh.Repository, error)
- func (c *FixtureClient) GetUser(_ context.Context, login string) (*gh.User, error)
- func (c *FixtureClient) InvalidateListETagsForRepo(_, _ string, _ ...string)
- func (c *FixtureClient) ListCheckRunsForRef(_ context.Context, owner, repo, ref string) ([]*gh.CheckRun, error)
- func (c *FixtureClient) ListCommits(_ context.Context, _, _ string, _ int) ([]*gh.RepositoryCommit, error)
- func (c *FixtureClient) ListForcePushEvents(_ context.Context, _, _ string, _ int) ([]ghclient.ForcePushEvent, error)
- func (c *FixtureClient) ListIssueComments(_ context.Context, owner, repo string, number int) ([]*gh.IssueComment, error)
- func (c *FixtureClient) ListIssueCommentsIfChanged(ctx context.Context, owner, repo string, number int) ([]*gh.IssueComment, error)
- func (c *FixtureClient) ListIssuesPage(_ context.Context, _, _, _ string, _ int) ([]*gh.Issue, bool, error)
- func (c *FixtureClient) ListOpenIssues(_ context.Context, owner, repo string) ([]*gh.Issue, error)
- func (c *FixtureClient) ListOpenPullRequests(_ context.Context, owner, repo string) ([]*gh.PullRequest, error)
- func (c *FixtureClient) ListPullRequestsPage(_ context.Context, _, _, _ string, _ int) ([]*gh.PullRequest, bool, error)
- func (c *FixtureClient) ListRepositoriesByOwner(ctx context.Context, owner string) ([]*gh.Repository, error)
- func (c *FixtureClient) ListReviews(_ context.Context, _, _ string, _ int) ([]*gh.PullRequestReview, error)
- func (c *FixtureClient) ListWorkflowRunsForHeadSHA(_ context.Context, _, _, _ string) ([]*gh.WorkflowRun, error)
- func (c *FixtureClient) MarkPullRequestReadyForReview(_ context.Context, owner, repo string, number int) (*gh.PullRequest, error)
- func (c *FixtureClient) MergePullRequest(_ context.Context, owner, repo string, number int, _, _, _ string) (*gh.PullRequestMergeResult, error)
- type SeedResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFixtureClient ¶
NewFixtureClient returns a FixtureClient with empty fixture maps.
func SeedRoborevDB ¶
SeedRoborevDB creates a roborev-compatible SQLite database at path with deterministic test data. The database contains ~75 review jobs across 2 repos, 5 branches, 3 agents, and all statuses.
Types ¶
type DiffRepoResult ¶
type DiffRepoResult struct {
BaseSHA string // merge-base / base branch tip
HeadSHA string // PR head commit
Manager *gitclone.Manager
FileCount int // number of changed files (excluding whitespace-only when hidden)
AddedFiles []string
DeletedFiles []string
}
DiffRepoResult holds the SHAs from the test repo for use in assertions.
func SetupDiffRepo ¶
SetupDiffRepo creates a git repository with known commits and wires it into the database so the diff endpoint works without mocking.
The repo is set up for acme/widgets PR #1. It creates:
- Modified file with 2 hunks (internal/handler.go)
- Added file (internal/cache.go)
- Deleted file (config.yaml)
- Whitespace-only change (README.md)
Returns a clone manager and metadata about the created diff.
type FixtureClient ¶
type FixtureClient struct {
OpenPRs map[string][]*gh.PullRequest
PRs map[string][]*gh.PullRequest
OpenIssues map[string][]*gh.Issue
Issues map[string][]*gh.Issue
Comments map[string][]*gh.IssueComment
ReposByOwner map[string][]*gh.Repository
CombinedStatuses map[string]*gh.CombinedStatus
CheckRuns map[string][]*gh.CheckRun
ListRepositoriesByOwnerFn func(context.Context, string) ([]*gh.Repository, error)
// contains filtered or unexported fields
}
FixtureClient is a ghclient.Client implementation for E2E tests. It serves seeded PRs and issues from the list methods and stubs out everything else.
func (*FixtureClient) ApproveWorkflowRun ¶
ApproveWorkflowRun returns an error (mutations not supported).
func (*FixtureClient) CreateIssueComment ¶
func (c *FixtureClient) CreateIssueComment( _ context.Context, owner, repo string, number int, body string, ) (*gh.IssueComment, error)
func (*FixtureClient) CreateReview ¶
func (c *FixtureClient) CreateReview( _ context.Context, _, _ string, _ int, _, _ string, ) (*gh.PullRequestReview, error)
CreateReview returns an error (mutations not supported).
func (*FixtureClient) EditIssue ¶
func (c *FixtureClient) EditIssue( _ context.Context, owner, repo string, number int, state string, ) (*gh.Issue, error)
EditIssue updates the seeded issue state for E2E mutations.
func (*FixtureClient) EditPullRequest ¶
func (c *FixtureClient) EditPullRequest( _ context.Context, owner, repo string, number int, opts ghclient.EditPullRequestOpts, ) (*gh.PullRequest, error)
EditPullRequest updates seeded PR fields for E2E mutations.
func (*FixtureClient) GetCombinedStatus ¶
func (c *FixtureClient) GetCombinedStatus( _ context.Context, owner, repo, ref string, ) (*gh.CombinedStatus, error)
GetCombinedStatus returns a seeded combined status by repo/ref.
func (*FixtureClient) GetIssue ¶
func (c *FixtureClient) GetIssue( _ context.Context, owner, repo string, number int, ) (*gh.Issue, error)
GetIssue looks up the issue by owner/repo and number from the seeded fixture set. Returns nil, nil if not found.
func (*FixtureClient) GetPullRequest ¶
func (c *FixtureClient) GetPullRequest( _ context.Context, owner, repo string, number int, ) (*gh.PullRequest, error)
GetPullRequest looks up the PR by owner/repo and number from the seeded fixture set. Returns nil, nil if not found.
func (*FixtureClient) GetRepository ¶
func (c *FixtureClient) GetRepository( _ context.Context, owner, repo string, ) (*gh.Repository, error)
GetRepository returns a repository with all merge methods enabled.
func (*FixtureClient) InvalidateListETagsForRepo ¶
func (c *FixtureClient) InvalidateListETagsForRepo(_, _ string, _ ...string)
InvalidateListETagsForRepo is a no-op for the fixture client, which has no underlying HTTP cache.
func (*FixtureClient) ListCheckRunsForRef ¶
func (c *FixtureClient) ListCheckRunsForRef( _ context.Context, owner, repo, ref string, ) ([]*gh.CheckRun, error)
ListCheckRunsForRef returns seeded check runs by repo/ref.
func (*FixtureClient) ListCommits ¶
func (c *FixtureClient) ListCommits( _ context.Context, _, _ string, _ int, ) ([]*gh.RepositoryCommit, error)
ListCommits returns nil (read-only stub).
func (*FixtureClient) ListForcePushEvents ¶
func (c *FixtureClient) ListForcePushEvents( _ context.Context, _, _ string, _ int, ) ([]ghclient.ForcePushEvent, error)
ListForcePushEvents returns nil (read-only stub).
func (*FixtureClient) ListIssueComments ¶
func (c *FixtureClient) ListIssueComments( _ context.Context, owner, repo string, number int, ) ([]*gh.IssueComment, error)
ListIssueComments returns nil (read-only stub).
func (*FixtureClient) ListIssueCommentsIfChanged ¶
func (c *FixtureClient) ListIssueCommentsIfChanged( ctx context.Context, owner, repo string, number int, ) ([]*gh.IssueComment, error)
func (*FixtureClient) ListIssuesPage ¶
func (c *FixtureClient) ListIssuesPage( _ context.Context, _, _, _ string, _ int, ) ([]*gh.Issue, bool, error)
ListIssuesPage returns nil (read-only stub).
func (*FixtureClient) ListOpenIssues ¶
func (c *FixtureClient) ListOpenIssues( _ context.Context, owner, repo string, ) ([]*gh.Issue, error)
ListOpenIssues returns the seeded open issues for the given repo.
func (*FixtureClient) ListOpenPullRequests ¶
func (c *FixtureClient) ListOpenPullRequests( _ context.Context, owner, repo string, ) ([]*gh.PullRequest, error)
ListOpenPullRequests returns the seeded open PRs for the given repo.
func (*FixtureClient) ListPullRequestsPage ¶
func (c *FixtureClient) ListPullRequestsPage( _ context.Context, _, _, _ string, _ int, ) ([]*gh.PullRequest, bool, error)
ListPullRequestsPage returns nil (read-only stub).
func (*FixtureClient) ListRepositoriesByOwner ¶
func (c *FixtureClient) ListRepositoriesByOwner( ctx context.Context, owner string, ) ([]*gh.Repository, error)
func (*FixtureClient) ListReviews ¶
func (c *FixtureClient) ListReviews( _ context.Context, _, _ string, _ int, ) ([]*gh.PullRequestReview, error)
ListReviews returns nil (read-only stub).
func (*FixtureClient) ListWorkflowRunsForHeadSHA ¶
func (c *FixtureClient) ListWorkflowRunsForHeadSHA( _ context.Context, _, _, _ string, ) ([]*gh.WorkflowRun, error)
ListWorkflowRunsForHeadSHA returns nil (read-only stub).
func (*FixtureClient) MarkPullRequestReadyForReview ¶
func (c *FixtureClient) MarkPullRequestReadyForReview( _ context.Context, owner, repo string, number int, ) (*gh.PullRequest, error)
func (*FixtureClient) MergePullRequest ¶
func (c *FixtureClient) MergePullRequest( _ context.Context, owner, repo string, number int, _, _, _ string, ) (*gh.PullRequestMergeResult, error)
MergePullRequest returns an error (mutations not supported).
type SeedResult ¶
type SeedResult struct {
// FixtureClient builds a FixtureClient populated with the seeded open items.
FixtureClient func() *FixtureClient
}
SeedResult holds references to seeded data for use in E2E tests.
func OpenFixtureTestDB ¶
func OpenFixtureTestDB(t *testing.T) (*db.DB, *SeedResult)
OpenFixtureTestDB opens a temporary SQLite database seeded with fixture data. It returns the DB and SeedResult. The DB is closed automatically via t.Cleanup.
func SeedFixtures ¶
SeedFixtures populates d with a synthetic data set for E2E tests and returns a SeedResult containing a FixtureClient factory for the seeded open items.