The mock server is implemented in internal/mockserver/ as an httptest.Server backed by an in-memory Scenario.
It handles all GraphQL query patterns sent by github.Client, using string-based query routing.
The mock serve CLI command in cmd/mock.go provides a user-friendly interface for starting the server with configurable presets and parameters.
A. Fluent builder:
NewScenarioBuilder(owner, repo) ──► AddIssue/AddPR ──► Build()
B. Simulation generator:
Generate(SimulationConfig) ──► timeline events ──► chronological processing ──► Scenario
C. Time-advance:
ScenarioBuilder.AdvanceTime(delta) ──► TimeAdvance ──► NewIssue/NewPR/Comment/Merge/Close ──► Build()
Data Models
SimulationConfig
Field
Type
Constraints
Description
NumUsers
int
> 0
Number of simulated GitHub users
Repos
[]string
>= 1
Repositories in "owner/repo" format
History
time.Duration
> 0
Duration of simulated history
IssuesPerRepo
int
>= 0
Issues to create per repository
PRsPerRepo
int
>= 0
PRs to create per repository
CommentsPerIssue
int
>= 0
Max comments per issue
CommentsPerPR
int
>= 0
Max comments per PR
AssigneesPerIssue
int
>= 0
Max assignees per issue
AssigneesPerPR
int
>= 0
Max assignees per PR
LabelsPerItem
int
>= 0
Max labels per item
MilestonesPerRepo
int
>= 0
Milestones per repo
CloseRate
float64
[0, 1]
Fraction of issues closed
MergeRate
float64
[0, 1]
Fraction of PRs merged
DraftRate
float64
[0, 1]
Fraction of PRs as drafts
ReviewRate
float64
[0, 1]
Fraction of PRs with review decision
Seed
int64
RNG seed for deterministic output
Now
time.Time
Reference time (defaults to time.Now())
ActivityBursts
int
>= 0
Number of high-activity windows
Scenario
Field
Type
Description
Issues
[]ScenarioIssue
All mock issues (embeds github.Issue with owner/repo)
PRs
[]ScenarioPR
All mock PRs (embeds github.PullRequest with owner/repo)
Server
Field
Type
Description
mu
sync.RWMutex
Protects scenario for concurrent access
scenario
*Scenario
Current scenario data
server
*httptest.Server
Underlying HTTP test server
API Contracts
The mock server exposes a single POST / endpoint that accepts GraphQL requests matching the GitHub API contract.
All 7 query patterns are routed by string matching on the query body.