testkit

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: Apache-2.0 Imports: 12 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 testkit provides the single in-process GitHub API double for adapter and gateway conformance. It has no external credentials or I/O.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeGitHub

type FakeGitHub = GitHub

FakeGitHub is the reconciliation suite's name for the shared adapter fake.

type GitHub

type GitHub struct {
	// contains filtered or unexported fields
}

GitHub is an httptest GitHub that models the endpoints the adapter uses, with git's content addressing for blobs: a blob's ID is its real SHA-1, so the adapter's blob checks are exercised for real. Trees and commits get stable made-up IDs, and every commit is unique, as on GitHub, where the commit time is part of the ID.

func New

func New(t testing.TB) *GitHub

func NewFakeGitHub

func NewFakeGitHub(t *testing.T) *GitHub

func NewFakeGitHubFor

func NewFakeGitHubFor(t *testing.T, owner, name string) *GitHub

func (*GitHub) AdvanceBranch

func (f *GitHub) AdvanceBranch(branch string) string

AdvanceBranch models another writer advancing a branch after preparation.

func (*GitHub) AppliedPull

func (f *GitHub) AppliedPull(head string) int

AppliedPull counts successful provider pull creation writes for a branch.

func (*GitHub) AppliedRef

func (f *GitHub) AppliedRef(head string) int

AppliedRef counts successful provider ref writes for the full ref name.

func (*GitHub) BaseSHA

func (f *GitHub) BaseSHA() string

BaseSHA is the current main branch head.

func (*GitHub) CompleteMerge

func (f *GitHub) CompleteMerge(number int64)

CompleteMerge makes the queued effect visible through the authoritative read.

func (*GitHub) EditPull

func (f *GitHub) EditPull(number int64, edit func(*PullRequest))

EditPull models an independent provider-side change under the fixture lock.

func (*GitHub) Head

func (f *GitHub) Head(branch string) string

Head returns the current fixture branch head.

func (*GitHub) HeadSHA

func (f *GitHub) HeadSHA(head string) string

HeadSHA is the current head for a branch.

func (*GitHub) MarkReady

func (f *GitHub) MarkReady(number int64)

markReady turns a draft into a ready pull request, as a person would.

func (*GitHub) MergeReads

func (f *GitHub) MergeReads() int

MergeReads counts authoritative pull-number reads for merge reconciliation.

func (*GitHub) MergeRequests

func (f *GitHub) MergeRequests() int

MergeRequests counts attempted provider merge writes, including refusals.

func (*GitHub) Name

func (f *GitHub) Name() string

Name is the fixture repository name.

func (*GitHub) Owner

func (f *GitHub) Owner() string

Owner is the fixture repository's owner.

func (*GitHub) PullNumber

func (f *GitHub) PullNumber(head string) int64

PullNumber returns the pull created from the named fixture branch.

func (*GitHub) PullReads

func (f *GitHub) PullReads(head string) int

PullReads counts provider pull list readbacks for a branch.

func (*GitHub) PushRequests

func (f *GitHub) PushRequests() int

PushRequests counts attempted ref updates, including refused ones.

func (*GitHub) RefReads

func (f *GitHub) RefReads(head string) int

RefReads counts provider ref readbacks for a branch.

func (*GitHub) Repository

func (f *GitHub) Repository() string

Repository is the fixture repository's name.

func (*GitHub) RewindBranch

func (f *GitHub) RewindBranch(branch string) string

RewindBranch models a concurrent forced move to the current commit's parent.

func (*GitHub) RewriteBranchFile

func (f *GitHub) RewriteBranchFile(branch, path, content string) string

RewriteBranchFile models a concurrent force rewrite with the same parents and a different blob, keeping content and parent mismatch controls distinct.

func (*GitHub) SetApplyThenDrop

func (f *GitHub) SetApplyThenDrop(ref, pull bool)

SetApplyThenDrop drops the response after a successful ref or pull write.

func (*GitHub) SetMergeMode

func (f *GitHub) SetMergeMode(mode string)

SetMergeMode selects an acknowledged queue, pending request, or actual merge.

func (*GitHub) SetReadback

func (f *GitHub) SetReadback(branch, pull ReadbackMode)

SetReadback controls provider read visibility without changing provider state.

func (*GitHub) Token

func (f *GitHub) Token() string

Token is a fake-only accepted installation credential.

func (*GitHub) URL

func (f *GitHub) URL() string

URL returns the local REST server origin.

type PullRequest

type PullRequest struct {
	Number         int64
	Title          string
	Body           string
	Head, Base     string
	HeadSHA        string
	Draft          bool
	State          string
	Merged         bool
	MergeCommitSHA string
	Stack          json.RawMessage
	HeadRepository string
	BaseRepository string
}

type ReadbackMode

type ReadbackMode string

ReadbackMode controls visibility while preserving applied provider state.

const (
	ReadbackNormal       ReadbackMode = "normal"
	ReadbackAbsent       ReadbackMode = "absent"
	ReadbackMismatch     ReadbackMode = "mismatch"
	ReadbackInconclusive ReadbackMode = "inconclusive"
)

Jump to

Keyboard shortcuts

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