Documentation
¶
Overview ¶
Package harness builds and drives the real heraut binary for the e2e suite (ADR-0066).
Index ¶
- func Binary(t testing.TB, tags ...string) string
- func Cleanup()
- type GitHub
- type GitLab
- type Hang
- type Process
- type Repo
- func (r *Repo) APICalls() []string
- func (r *Repo) AddRemote()
- func (r *Repo) Checkout(branch string)
- func (r *Repo) Commit(msg string)
- func (r *Repo) Detach()
- func (r *Repo) FakeGitHub() *GitHub
- func (r *Repo) FakeGitLab() *GitLab
- func (r *Repo) Git(args ...string) string
- func (r *Repo) GitRemote(args ...string) string
- func (r *Repo) Home() string
- func (r *Repo) MergeNoFF(branch string)
- func (r *Repo) PushOptions() [][]string
- func (r *Repo) ReadFile(rel string) string
- func (r *Repo) RecordPushOptions()
- func (r *Repo) RemoveRemote()
- func (r *Repo) RestoreRemote(rev string)
- func (r *Repo) Run(bin string, env []string, args ...string) Result
- func (r *Repo) RunStdin(bin string, env []string, stdin string, args ...string) Result
- func (r *Repo) Start(bin string, env []string, args ...string) *Process
- func (r *Repo) Switch(branch string)
- func (r *Repo) Tag(name string)
- func (r *Repo) WriteConfig(yaml string)
- func (r *Repo) WriteFile(rel, content string)
- func (r *Repo) WriteHomeFile(rel, content string)
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GitHub ¶ added in v0.82.0
type GitHub struct {
URL string
// contains filtered or unexported fields
}
GitHub is a loopback stand-in for the GitHub REST API, laid out as a GitHub Enterprise Server without subdomain isolation: the API under /api/v3 and uploads under /api/uploads, on one origin. It answers 200 to reads (an empty array for a releases list), 201 to release creation and uploads (with the uploaded name rewritten as GitHub does: "#" becomes "."), 200 to the publish PATCH and 204 to a delete. Every request is logged as "github [METHOD] [/path]" in the call log both stand-ins share, so a test can assert on the order of calls across forges.
func (*GitHub) FailReleases ¶ added in v0.82.0
func (g *GitHub) FailReleases()
FailReleases makes every following release creation answer 403 (the call is still logged).
func (*GitHub) FailUploads ¶ added in v0.82.0
func (g *GitHub) FailUploads()
FailUploads makes every following asset upload answer 422, as GitHub does for a duplicate name (the call is still logged).
func (*GitHub) Hang ¶ added in v0.83.0
Hang makes every following request of kind wait without answering until the client gives up (the call is still logged, and an upload is not accepted). The returned channel is closed when the first such request arrives, so a test can act while the client waits.
type GitLab ¶ added in v0.77.0
type GitLab struct {
URL string
// contains filtered or unexported fields
}
GitLab is a loopback stand-in for the GitLab REST API. It answers 200 to reads (an empty array for a releases list), 201 to uploads and release creation, and logs every request as "gitlab [METHOD] [/decoded/path]" in the call log both stand-ins share, so a test can assert on the order of calls across forges.
func (*GitLab) FailReleases ¶ added in v0.77.0
func (g *GitLab) FailReleases()
FailReleases makes every following release creation answer 403 (the call is still logged).
type Hang ¶ added in v0.83.0
type Hang int
Hang names a kind of request the stand-in can be told to leave unanswered.
type Process ¶ added in v0.82.0
type Process struct {
// contains filtered or unexported fields
}
Process is a command started in the background by Repo.Start, for a scenario that acts while it runs (an interrupt, for one).
func (*Process) Interrupt ¶ added in v0.82.0
Interrupt sends the process SIGINT, as Ctrl-C in a terminal does.
type Repo ¶
type Repo struct {
Dir string
// contains filtered or unexported fields
}
Repo is a throwaway git repository with deterministic identity and no signing.
func NewRepo ¶
NewRepo initialises an empty repository on branch main; it skips when git is not on PATH.
func (*Repo) APICalls ¶ added in v0.82.0
APICalls returns every request the stand-ins of this repository received, oldest first, as "forge [METHOD] path".
func (*Repo) AddRemote ¶
func (r *Repo) AddRemote()
AddRemote creates a bare repository, wires it as origin and pushes the current branch with upstream tracking. The repository needs at least one commit.
func (*Repo) FakeGitHub ¶ added in v0.82.0
FakeGitHub starts the stand-in for this repository (once; later calls return the same one) and shuts it down with the test. Point a forge's base_url at URL. The call log exists from here on.
func (*Repo) FakeGitLab ¶ added in v0.77.0
FakeGitLab starts the stand-in for this repository (once; later calls return the same one) and shuts it down with the test. Point a forge's base_url at URL. The call log exists from here on.
func (*Repo) PushOptions ¶ added in v0.84.0
PushOptions returns the options of every push the remote received since RecordPushOptions, one entry per push in order. A push without options is an empty entry.
func (*Repo) RecordPushOptions ¶ added in v0.84.0
func (r *Repo) RecordPushOptions()
RecordPushOptions makes the bare remote accept push options and record them; read them back with PushOptions. Call it after AddRemote.
func (*Repo) RemoveRemote ¶
func (r *Repo) RemoveRemote()
RemoveRemote deletes the bare remote so a later push fails.
func (*Repo) RestoreRemote ¶
RestoreRemote recreates the bare remote removed by RemoveRemote, holding only main at rev (typically the commit the remote had before the failed push), so a retry meets a remote that is reachable again but still behind.
func (*Repo) Run ¶
Run executes bin with args inside the repository. The environment is built from scratch (PATH, HOME, NO_COLOR, ...) plus env, so ambient CI variables never reach the binary.
func (*Repo) Start ¶ added in v0.82.0
Start runs bin with args inside the repository, with the environment Run uses, and returns at once. The test must call Wait.
func (*Repo) WriteConfig ¶
WriteConfig writes .heraut.yml at the repository root.
func (*Repo) WriteFile ¶
WriteFile writes content to a path relative to the repository root, creating directories.
func (*Repo) WriteHomeFile ¶
WriteHomeFile writes content to a path relative to HOME, creating directories.