Help us shape the future of Go! Take the 2026 Go Developer Survey

github

package
v8.134.3 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package github mocks the GitHub REST API and the device-flow endpoints of github.com on one server: DEVCTL_GITHUB_API_URL and DEVCTL_GITHUB_OAUTH_URL both point at it. Every response comes from the scenario's route sequences; the mock adds what the real API adds and a client relies on: the rate-limit headers the poll interval is read from, an ETag on every successful body, and 304 Not Modified when a conditional request carries that ETag.

Index

Constants

This section is empty.

Variables

View Source
var NotFound = sequence.Response{
	Status: http.StatusNotFound,
	Body: map[string]any{
		"message":           "Not Found",
		"documentation_url": "https://docs.github.com/rest",
		"status":            "404",
	},
}

NotFound is what an unscripted route answers, the way api.github.com does.

Functions

func ETag

func ETag(body []byte) string

ETag is the tag the mock gives a body: a fixture that wants to assert on it computes the same.

Types

type Server

type Server struct {
	*httptest.Server
	// contains filtered or unexported fields
}

Server is a running mock.

func Start

func Start(routes sequence.Routes) (*Server, error)

Start serves the routes on a loopback port until Close.

func (*Server) Requests

func (s *Server) Requests() []sequence.Request

Requests are the requests received so far.

Jump to

Keyboard shortcuts

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