testing library

Test support for code that talks to GitHub: an in-memory GitHub.

FakeGitHubServer serves the git data API (refs, commits, trees, blobs with real content addressing and the non-fast-forward refusal), the contents API, and issues, labels, comments and search, behind an http.Client that any caller — a GitHubApiClient included — is handed in place of the network. The canned responses (rateLimited, secondaryRateLimited, serverError, unauthorized) drive a caller's backoff and failure paths.

This is a separate entry point so that nothing importing package:tom_github_api/tom_github_api.dart links a test double. Import it from tests only.

Classes

FakeComment
FakeCommit
FakeGitHubRepo
A repository: its default branch, its refs, the object store they resolve into, and its issues.
FakeGitHubServer
The fake server. Wire it into a client with GitHubApiClient(token: 'x', httpClient: server.client, baseUrl: FakeGitHubServer.baseUrl).
FakeIssue
An issue as the fake stores it. Mutable, because that is what an issue is.

Functions

rateLimited(DateTime reset) → Response
A primary rate-limit refusal: quota exhausted until reset.
secondaryRateLimited({bool blocked = false, Duration? retryAfter}) → Response
A secondary rate-limit refusal — GitHub saying "too fast", not "not allowed".
serverError() → Response
A transient server-side failure — the one class of error that gets exponential backoff, because GitHub advertises no wait for it.
unauthorized() → Response
A refused credential. Never retried: waiting cannot make a bad token good.