Documentation
¶
Overview ¶
Package httpmock provides HTTP test fakes for the ghapi client.
Index ¶
- func BranchListResponse(pairs ...string) any
- func BranchListResponseProtected(triples ...any) any
- func CompareAncestorResponse(mergeBaseSHA string) any
- func GitRefResponse(qualified, sha string) any
- func NoTagsNamed(reg *Registry, owner, repo string)
- func TagListResponse(pairs ...string) any
- type Matcher
- type Registry
- type Responder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BranchListResponse ¶
BranchListResponse builds a REST list-branches response body. pairs are (name, sha) alternating, e.g. BranchListResponse("main", "abc", "dev", "def"). All entries are marked protected:true so tests model trusted-upstream branches by default; use BranchListResponseProtected to mix protected and unprotected entries.
func BranchListResponseProtected ¶
BranchListResponseProtected builds a REST list-branches response body where each entry is a (name, sha, protected) triple.
func CompareAncestorResponse ¶
CompareAncestorResponse builds a REST compare response indicating the requested sha is an ancestor of the head, with the given merge-base sha.
func GitRefResponse ¶ added in v0.3.0
GitRefResponse is a git/ref body for the exact ref qualified (refs/tags/x or refs/heads/x) pointing at a commit.
func NoTagsNamed ¶ added in v0.3.0
NoTagsNamed answers every exact tag lookup in owner/repo with 404, for tests whose branches have no same-named tag.
func TagListResponse ¶
TagListResponse builds a REST list-tags response body. pairs are (name, sha) alternating.
Types ¶
type Matcher ¶
Matcher determines whether a stub matches an outbound request.
func GraphQLForRepo ¶
GraphQLForRepo matches any GraphQL request whose query or variables reference the given repository owner/name. This is the preferred matcher for queries that pass owner/name through GraphQL `$variables` rather than interpolating them as string literals.
func RESTWithQuery ¶
RESTWithQuery is like REST but also requires querySubstring to appear in the request's raw query string. Use this to distinguish calls that share a URL path but differ by query parameter (e.g. branches?protected=true vs branches?per_page=100).
type Registry ¶
Registry records requests and serves stubbed responses. It mirrors the cli/cli pkg/httpmock usage pattern for deterministic API tests.
func (*Registry) RegisterReusable ¶ added in v0.3.0
RegisterReusable adds a matcher/response pair that serves every matching request rather than just the first. Verify doesn't require it to match.
type Responder ¶
Responder builds an HTTP response for a matched request.
func GraphQLQuery ¶
GraphQLQuery inspects the outbound GraphQL request before returning a body.
func JSONResponse ¶
JSONResponse turns a value into a 200 JSON response.
func StatusResponse ¶
StatusResponse returns a response with the given status code and empty body.