ghfake

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package ghfake implements a fake GitHub REST API server for local e2e testing.

The server implements the subset of the GitHub API that ephemerd's pkg/github.Client uses: PollJobs, RegisterJITRunner, RemoveRunner, and FetchJobImage. It runs as an httptest.Server and returns a configured github.Client pointing at it.

Usage:

srv := ghfake.New("myorg")
defer srv.Close()
srv.QueueJob("myrepo", []string{"self-hosted", "linux", "x64"})

client := srv.Client()
events, _ := client.PollJobs(ctx)  // returns the queued job
jit, _ := client.RegisterJITRunner(ctx, "myrepo", "runner-1", labels)
// ... runner runs and exits ...
client.RemoveRunner(ctx, "myrepo", jit.GetRunner().GetID())
// srv.Removed(runnerID) == true

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server is a fake GitHub REST API backed by httptest.Server.

func New

func New(owner string) *Server

New creates and starts a fake GitHub server for the given org/owner.

func (*Server) Client

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

Client returns an ephemerd github.Client configured to talk to this fake server.

func (*Server) QueueJob

func (s *Server) QueueJob(repo string, labels []string) int64

QueueJob adds a job to the fake server's queue. Returns the job ID.

func (*Server) Removed

func (s *Server) Removed(runnerID int64) bool

Removed returns true if the runner with the given ID has been deregistered.

func (*Server) WaitForRemoval

func (s *Server) WaitForRemoval(runnerID int64, timeout time.Duration) bool

WaitForRemoval blocks until the specified runner is removed or the timeout expires. Returns true if removal was detected, false on timeout.

Jump to

Keyboard shortcuts

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