Documentation
¶
Overview ¶
Package assembletest builds the synthetic inputs of bundle assembly tests: a git clone whose pull request exercises every kind of change, a fake GitHub that returns evidence for it, and a fake session source. Everything is made up and deterministic: commit dates and identities are fixed, so the commit ids, and the bundle built from them, are the same on every run.
Index ¶
Constants ¶
const ( ImageSource = "https://github.com/user-attachments/assets/0f3b8c1e-5a4d-4e6f-9a7b-1c2d3e4f5a6b" ImageFetchURL = "https://private-user-images.githubusercontent.com/1/2-0f3b8c1e-5a4d-4e6f-9a7b-1c2d3e4f5a6b.png?jwt=signed" )
ImageSource is the description image's markdown source, and ImageFetchURL the signed URL GitHub renders for it.
const Number = 7
Number is the pull request's number.
const PlantedEmail = "ada.lovelace@example.com"
PlantedEmail is planted next to the secret.
Variables ¶
var PNG = mustDecode("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==")
PNG is a 1x1 PNG, the description image's content.
var PlantedSecret = "hf_" + "nW2OPJ0rGsD6y4OUtEXQxmAa3BItWMoP6J"
PlantedSecret is a made-up Hugging Face token, planted in the pull request's settings file, body, a comment and a session prompt. It must never reach a bundle. It is kept in pieces so no source line reads as a credential.
var Repository = github.Repository{Host: "github.com", Owner: "acme", Name: "demo"}
Repository is the pull request's repository on GitHub.
Functions ¶
func SessionTree ¶
SessionTree is what the local session source returns for a top-level session whose second prompt spawned a subagent that spawned another: each prompt carries the paths the sessions it started, at any depth, touched. A second, earlier-starting session ran in the same pull request. Both carry the planted secret and e-mail address in their text.
Types ¶
type GitHub ¶
type GitHub struct {
Evidence github.Evidence
Err error
// Fetched records each pull request asked for.
Fetched []github.Target
}
GitHub is a fake GitHub: it returns Evidence, or Err, for the pull request.
type Options ¶
type Options struct {
// NoReviewMD leaves REVIEW.md out of the base commit.
NoReviewMD bool
}
Options vary the fixture.
type Repo ¶
type Repo struct {
Dir string
// Base is main's tip, Head the pull request's tip, MergeBase their merge
// base, which is the commit before the pull request's work: main moved on
// after the branch point, so the base is not the merge base.
Base, Head, MergeBase string
// Commits are the pull request's commits, oldest first.
Commits []string
// ShiftHead and ShiftBase are a second pull request making the same
// change to src/shift.go as the first, against a base that has three more
// lines above it: a context shift.
ShiftHead, ShiftBase string
}
Repo is a clone with a pull request on branch "feature". The clone's HEAD is on main, as when a user reads a pull request they are not working on.
func NewRepo ¶
NewRepo creates the fixture clone in a temporary directory. The pull request, on branch feature, in two commits:
- adds the same line twice to src/list.go (repeated hunks), adds config/settings.env holding PlantedSecret, edits src/shift.go, and adds a docs/ page;
- renames docs/old-guide.md to docs/guide.md with one line changed (a rename), and changes assets/logo.bin (a binary change).
Main then gains a commit, so the base commit is not the merge base.
func (Repo) Dirty ¶
Dirty leaves the clone with a modified tracked file, a staged change and an untracked file, so a test can tell whether anything touched them.
func (Repo) Evidence ¶
Evidence is what GitHub returns for the pull request at r's head: every part present, with a check run, a status, a conversation, a thread and a description image.
func (Repo) EvidenceMissing ¶
EvidenceMissing is the pull request with nothing but its header: no checks, conversation, threads or images, and every other part unreadable.
func (Repo) ShiftEvidence ¶
ShiftEvidence is the header of the context-shift pull request: the same change to src/shift.go as the main pull request's, against a base with three more lines above it.