githubtest

package
v0.0.0-...-481e254 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 11 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 githubtest is a fake GitHub REST API for tests of the publish github target and of the publish command.

Index

Constants

View Source
const (
	Owner = "acme"
	Repo  = "demo"
)

Owner and Repo are the one repository the fake serves.

View Source
const Token = "tok"

Token is the credential the fake accepts, as "Bearer Token".

Variables

This section is empty.

Functions

This section is empty.

Types

type Issue

type Issue struct {
	ID     int64    `json:"id"`
	Number int      `json:"number"`
	URL    string   `json:"html_url"`
	Title  string   `json:"title"`
	Body   string   `json:"body"`
	State  string   `json:"state"`
	Labels []string `json:"-"`
}

type Server

type Server struct {
	URL string
	// Labels the repo has; publish applies only these.
	Labels []string
	Issues map[int]*Issue

	Subs    map[int][]int64 // parent number -> child ids
	Blocked map[int][]int64 // issue number -> blocker ids

	FailSubs bool
	// contains filtered or unexported fields
}

Server is enough of the REST API for the target: labels, issue create and patch, search by body, sub-issues and blocked-by, recording each call.

func New

func New(t *testing.T) *Server

New starts the fake with the labels epic and bug and stops it with the test.

func (*Server) Calls

func (f *Server) Calls() int

Calls is how many requests the fake has served.

func (*Server) Count

func (f *Server) Count(call string) int

Count is how many times "METHOD /path" was called.

func (*Server) ServeHTTP

func (f *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Server) Snapshot

func (f *Server) Snapshot() State

Snapshot copies the issues, sub-issue and blocked-by relations.

func (*Server) Target

func (f *Server) Target() *github.Target

Target is a target pointed at the fake with its credential.

func (*Server) Update

func (f *Server) Update(number int, fn func(*Issue))

Update changes an issue under the lock, for tests that alter the target's state between runs.

type State

type State struct {
	Issues  map[int]Issue
	Subs    map[int][]int64
	Blocked map[int][]int64
}

State is a copy of the fake's issues and relations taken under the lock, for readers outside a handler.

Jump to

Keyboard shortcuts

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