Documentation
¶
Overview ¶
Package ghtest provides minimal test helpers for code that uses ghkit. It is shape-correct, not behaviour-correct: see TESTING.md for the full recipe set and the boundary the helpers do and do not cover.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ETagServer ¶ added in v1.5.0
ETagServer simulates GitHub's server-side ETag behaviour: a request whose If-None-Match matches the body hash gets a 304, otherwise a 200 with the precomputed ETag. The *int64 counts requests so callers can assert wire hits. Registered with t.Cleanup.
func LinkHeader ¶ added in v1.4.0
LinkHeader builds an RFC 8288 Link header value for pagination fixtures. baseURL is the request URL without the page or per_page query string (e.g. "https://api.example/items"); page and perPage are 1-indexed; lastPage is the final page number.
First page omits prev and first; last page omits next and last. Returns "" when lastPage <= 1, the convention go-github sees on a single-page response.
func Write304IfMatch ¶
Write304IfMatch computes the expected ETag for body using the bored-engineer algorithm (which hashes the request's Authorization, Accept, and Cookie headers along with the body). If any tag in If-None-Match (split on commas, trimmed, and normalised to strip the W/ weak prefix and surrounding quotes) matches, it sets a quoted ETag response header per RFC 7232, writes 304 Not Modified with empty body, and returns true. Otherwise it writes nothing and returns false.
func WriteSecondaryLimit ¶
func WriteSecondaryLimit(w http.ResponseWriter, retryAfter time.Duration)
WriteSecondaryLimit writes a 403 with a Retry-After header (whole seconds) and a JSON body whose documentation_url ends in #secondary-rate-limits. That suffix is what go-github pattern-matches on to classify the error as an AbuseRateLimitError, so the consumer's retry path actually triggers in tests. Negative durations are clamped to zero.
Types ¶
This section is empty.