Documentation
¶
Overview ¶
Package mockgithub provides an in-process GitHub API mock for testing.
Index ¶
- func NewClient(ts *httptest.Server) (*github.Client, error)
- func Usage(addr string) string
- type Dataset
- type Server
- type WorkflowRunBuilder
- func (b *WorkflowRunBuilder) Build() github.WorkflowRun
- func (b *WorkflowRunBuilder) WithBranch(branch string) *WorkflowRunBuilder
- func (b *WorkflowRunBuilder) WithConclusion(c string) *WorkflowRunBuilder
- func (b *WorkflowRunBuilder) WithName(name string) *WorkflowRunBuilder
- func (b *WorkflowRunBuilder) WithTimes(createdAt, updatedAt time.Time) *WorkflowRunBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Dataset ¶
type Dataset struct {
Org string
Teams []github.Team
Repos []github.Repository
Workflows map[string][]github.Workflow // "owner/repo" → workflows
Runs map[string][]github.WorkflowRun // "owner/repo/<workflowID>" → runs
}
Dataset holds all mock GitHub data served by the Server.
func LoadFromDeploymentCSV ¶
LoadFromDeploymentCSV loads a Dataset from a GitHub deployment throughput CSV. The CSV format is: period_start,period_end,count (output of --save-raw-data). Each row's count is expanded into individual workflow runs spread across the period.
func NewDataset ¶
NewDataset creates a Dataset with a single org/team/repo/workflow.
func RealisticDataset ¶
func RealisticDataset() *Dataset
RealisticDataset returns ~12 weeks of deployment data for two repos, anchored to the current time so it falls within any recent default date range.
func SmallDataset ¶
func SmallDataset() *Dataset
SmallDataset returns a small deterministic dataset with ~3 weeks of deployments anchored to the current time, so it falls within any recent default date range.
type Server ¶
Server is a mock GitHub API server backed by a Dataset.
func (*Server) ListenAndServe ¶
ListenAndServe starts the server on the given address (e.g., ":8081").
type WorkflowRunBuilder ¶
type WorkflowRunBuilder struct {
// contains filtered or unexported fields
}
WorkflowRunBuilder provides a fluent API for constructing test workflow runs.
func (*WorkflowRunBuilder) Build ¶
func (b *WorkflowRunBuilder) Build() github.WorkflowRun
Build returns the constructed WorkflowRun.
func (*WorkflowRunBuilder) WithBranch ¶
func (b *WorkflowRunBuilder) WithBranch(branch string) *WorkflowRunBuilder
func (*WorkflowRunBuilder) WithConclusion ¶
func (b *WorkflowRunBuilder) WithConclusion(c string) *WorkflowRunBuilder
func (*WorkflowRunBuilder) WithName ¶
func (b *WorkflowRunBuilder) WithName(name string) *WorkflowRunBuilder
func (*WorkflowRunBuilder) WithTimes ¶
func (b *WorkflowRunBuilder) WithTimes(createdAt, updatedAt time.Time) *WorkflowRunBuilder