githubpagestest

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package githubpagestest is an in-process fake of the slice of the GitHub REST API the github-pages hosting adapter calls, for tests only. The adapter speaks through the forge the way the site setup's forge stage does — `gh api` as the person who invoked the verb, never a token abcd holds — so the fake answers the adapter's API calls directly rather than over a socket, and fails them the way `gh api` does: an error naming the HTTP status.

It answers exactly these routes, and anything else is a 404:

GET  repos/{owner}/{repo}         the repository: private, has_pages
GET  repos/{owner}/{repo}/pages   the Pages site: build_type, cname, html_url
POST repos/{owner}/{repo}/pages   create the Pages site
PUT  repos/{owner}/{repo}/pages   change its source or custom domain

Index

Constants

View Source
const (
	GetRepo     = "GET repo"
	GetPages    = "GET pages"
	CreatePages = "POST pages"
	UpdatePages = "PUT pages"
)

Route keys name a route for Fail and for the call log.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pages

type Pages struct {
	BuildType string
	CNAME     string
	// HTMLURL, when set, is the address the site reports in place of the one
	// GitHub would derive from its domain or its repository.
	HTMLURL string
}

Pages is one repository's Pages site.

type Repo

type Repo struct {
	Private bool
	// Pages is nil while the repository has no Pages site.
	Pages *Pages
}

Repo is one repository the fake holds.

type Server

type Server struct {
	Mu    sync.Mutex
	Repos map[string]*Repo
	// Fail makes a route answer with this error.
	Fail map[string]error
	// Calls logs each call as "<route key> <body>".
	Calls []string
}

Server is the fake. Its fields are the forge's state; lock Mu to read them while a call may be in flight.

func New

func New() *Server

New is a fake holding one public repository, acme/widgets, with no Pages site yet.

func (*Server) API

func (s *Server) API(_ context.Context, method, path string, body []byte) ([]byte, error)

API answers one call, shaped as the adapter's API.

func (*Server) CallLog

func (s *Server) CallLog() []string

CallLog is a copy of the calls made so far.

Jump to

Keyboard shortcuts

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