Documentation
¶
Overview ¶
Package fakeactions is a stand-in for GitHub's Actions service.
It exists because "it needs a GitHub organization" was wrong, and believing it left the code that talks to GitHub the least tested thing in the repository. The vendored client tests itself exactly this way, so the approach is the upstream one rather than an invention.
What it buys is the class of bug that unit tests over billet's own types cannot reach. The worst defect in this project so far was calling AcquireJobs with ids taken from JobAssigned instead of JobAvailable: billet's types were self-consistent, every test passed, and the mistake existed only in the relationship between billet and the wire. A fake that speaks the wire catches it.
It is a real package rather than a _test.go file because two different test suites need it — the scale-set client's own, and the end-to-end one that runs the control plane, the node and a real container together. It has no production callers and must not acquire any.
IT IS DELIBERATELY NOT A SIMULATOR OF GITHUB'S BEHAVIOUR. It answers the handshake and serves whatever a test tells it to. Nothing here should be read as evidence of what the real service does; where billet depends on real behaviour, that behaviour was measured against the real API and written down where it is relied upon.
Index ¶
- func JitConfigJSON(runnerID int, name, encoded string) map[string]any
- func JobJSON(messageType string, requestID int64, event string, labels ...string) map[string]any
- func ListJSON(values ...map[string]any) map[string]any
- func MessageJSON(t *testing.T, id int, stats map[string]any, jobs ...map[string]any) map[string]any
- func ScaleSetJSON(id int, name, group string, labels ...string) map[string]any
- func SessionJSON(sessionID, owner string, set map[string]any, queueURL, queueToken string) map[string]any
- func StatisticsJSON(available, assigned int) map[string]any
- func WriteJSON(t *testing.T, w http.ResponseWriter, v any)
- type Request
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JitConfigJSON ¶
JitConfigJSON is what generatejitconfig returns.
The encoded config is opaque to billet — it is handed to the runner verbatim — so a placeholder is honest here in a way that a hand-built runner config would not be.
func JobJSON ¶
JobJSON is one message inside a batch.
messageType is one of JobAvailable, JobAssigned, JobStarted or JobCompleted. The distinction that matters most is the first two: an AVAILABLE job is one billet may bid for, and an ASSIGNED job is one it has been given. Acquiring by the wrong one is the defect this whole fake was built to catch.
func MessageJSON ¶
MessageJSON is the envelope the long poll returns.
THE BODY IS A JSON STRING, not a nested object. That is the real wire format — the client json.Unmarshals `body` a second time — and a fake that nests the array instead produces a parse error that reads like billet's bug.
func ScaleSetJSON ¶
ScaleSetJSON is the shape the service returns for a scale set.
func SessionJSON ¶
func SessionJSON(sessionID, owner string, set map[string]any, queueURL, queueToken string) map[string]any
SessionJSON is what the service returns when a listener opens a session.
The message queue URL points back at this same server, because a test that stood a second listener up somewhere else would be testing its own plumbing.
func StatisticsJSON ¶
StatisticsJSON is the capacity signal the service attaches to sessions and messages. Only the two fields billet reads are parameterised.
Types ¶
type Request ¶
Request is one call the client made, so a test can assert on what billet actually put on the wire rather than on what it meant to.
type Server ¶
Server is a fake Actions service, good enough to drive the REAL vendored client through a real HTTP round trip.
func New ¶
func New(t *testing.T, handler http.HandlerFunc) *Server
New starts a fake service. The handler serves the scale-set API; the authentication handshake is answered here, because every test needs it and none of them are about it.
func (*Server) AdminToken ¶
AdminToken mints the RS256 token the client reads an expiry out of.
func (*Server) Calls ¶
Calls returns every request whose path contains the fragment, so an assertion can name the endpoint it cares about rather than an index.
func (*Server) PrivateKeyPEM ¶
PrivateKeyPEM is the throwaway App key this server signs with, so a caller can build a client config that authenticates against it.