FakeGitHubServer class

The fake server. Wire it into a client with GitHubApiClient(token: 'x', httpClient: server.client, baseUrl: FakeGitHubServer.baseUrl).

Constructors

FakeGitHubServer()

Properties

actor ↔ String
The login every fake-authored issue and comment carries.
getter/setter pair
authenticatedUser ↔ String
The login of the token's owner: GitHub's author and committer of a commit whose request names neither.
getter/setter pair
beforeIssueUpdate ↔ void Function()?
Fired once, immediately before the next PATCH /issues/{n} is applied — the issue-body equivalent of beforeRefUpdate. Unlike a ref update the patch still succeeds, because GitHub offers no compare-and-swap here; noticing is the writer's job.
getter/setter pair
beforeRefUpdate ↔ void Function()?
Fired once, immediately before the next PATCH /git/refs/… is applied. This is the seam a test uses to land a competing commit inside another writer's read-modify-write window.
getter/setter pair
blobs → Map<String, Uint8List>
Content-addressed object stores, shared across repositories exactly as the fake's simplicity allows — shas are content hashes, so sharing is invisible.
final
canned → List<Response>
Status codes to answer the next requests with before serving normally. Used to exercise the rate-limit and 5xx backoff paths.
final
client → Client
no setter
commits → Map<String, FakeCommit>
final
contentCreationBlocked ↔ bool
While true, issue and comment writes are refused with a content-creation block, and everything else is served.
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
indexLag ↔ Duration
How long a newly created issue stays invisible to the list and search endpoints while GET /issues/{n} already serves it.
getter/setter pair
notModifiedCount ↔ int
How many requests were answered 304 Not Modified.
getter/setter pair
pageSizeOverride ↔ int?
How many issues a page of GET /issues and GET /search/issues holds, whatever per_page asks for. Set it low to exercise a paginated walk on a handful of issues instead of the several hundred it would otherwise take.
getter/setter pair
refusedLog → List<String>
The writes contentCreationBlocked refused, as METHOD path.
final
repos → Map<String, FakeGitHubRepo>
owner/repo → repository.
final
requestLog → List<String>
Every request path this server has answered, in order. Lets a test assert that a conditional poll really did cost nothing.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
searchIncomplete ↔ bool
When true, every search answers incomplete_results: true — GitHub's way of saying it gave up before seeing everything, which it does under load and past its 1000-result ceiling.
getter/setter pair
searchIndexExcludes → Set<int>
Issue numbers the search index has not absorbed, though the issue is in the repository and the list endpoint serves it.
final
staleRefReads ↔ int
How many reads of a ref answer with the sha it held before its most recent write — a read replica that has not caught up.
getter/setter pair
trees → Map<String, Map<String, String>>
tree sha → flat path → blob sha. Flat because the recursive listing is the only tree read the fake serves, and a flat map is the honest model of one.
final

Methods

bytesAt(String slug, String path, {String branch = 'main'}) → Uint8List?
The bytes at path on branch, or null. The general accessor: a repository holds encrypted containers as readily as YAML.
commitFiles(String slug, Map<String, String> files, {String branch = 'main', String message = 'test'}) → String
Commits files (path → text) onto branch, creating it if needed. The direct way for a test to play the part of a competing writer.
fileAt(String slug, String path, {String branch = 'main'}) → String?
The text at path on branch, or null. Only valid for the textual serializations — a KDBX container is not UTF-8 and must be read with bytesAt.
handle(Request request) → Response
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pathsOn(String slug, {String branch = 'main'}) → Set<String>
Every path on branch.
repo(String slug) → FakeGitHubRepo
seedComment(String slug, int number, String body, {String? author}) → FakeComment
Appends a comment directly — the fixture path for a comment written in the GitHub UI rather than by the code under test.
seedIssue(String slug, {required String title, String body = '', Set<String> labels = const {}, String state = 'open'}) → FakeIssue
Creates an issue directly — the fixture path, and the way a test plays the part of a human who opened the issue in the GitHub UI.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

baseUrl → const String
labelNameLimit → const int
GitHub caps a label name at 50 characters and answers 422 resource: Label, code: invalid above it.