ghtest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package ghtest is an in-memory fake of the parts of the GitHub REST API triage uses, for tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	*httptest.Server
	Login string

	Requests []string
	// contains filtered or unexported fields
}

Server is a fake GitHub.

func New

func New(t testing.TB) *Server

New starts a fake GitHub that is shut down when the test ends.

func (*Server) AddIssue

func (s *Server) AddIssue(repoName string, title, body string, labels ...string) gh.Issue

AddIssue creates an issue directly, as if someone used the website.

func (*Server) AddRepo

func (s *Server) AddRepo(name string)

AddRepo creates an empty repository.

func (*Server) Client

func (s *Server) Client() *gh.Client

Client returns a gh.Client pointed at the fake.

func (*Server) Comments

func (s *Server) Comments(repoName string, number int) []gh.Comment

Comments returns an issue's comments.

func (*Server) EditIssue

func (s *Server) EditIssue(repoName string, number int, edit func(*gh.Issue))

EditIssue changes an issue directly, as if someone used the website.

func (*Server) HideFromListing

func (s *Server) HideFromListing(repoName string, number int, hidden bool)

HideFromListing makes an issue missing from issue listings, as GitHub's eventually consistent listing sometimes does for new issues.

func (*Server) Issue

func (s *Server) Issue(repoName string, number int) gh.Issue

Issue returns a copy of an issue.

func (*Server) IssueCount

func (s *Server) IssueCount(repoName string) int

IssueCount returns how many issues a repo has.

func (*Server) LabelNames

func (s *Server) LabelNames(repoName string, number int) []string

LabelNames returns the names of an issue's labels.

func (*Server) RepoLabel

func (s *Server) RepoLabel(repoName, name string) (gh.Label, bool)

RepoLabel returns a label defined in a repo.

func (*Server) SetOffline

func (s *Server) SetOffline(offline bool)

SetOffline makes every request fail with a network error.

func (*Server) SetReadOnly

func (s *Server) SetReadOnly(name string, readOnly bool)

SetReadOnly makes writes to repo fail with 403.

Jump to

Keyboard shortcuts

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