ghtest

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 6 Imported by: 0

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 Write304IfMatch

func Write304IfMatch(w http.ResponseWriter, r *http.Request, body []byte) bool

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL