Documentation
¶
Overview ¶
Package clitest provides an in-memory fake of a Backyard server's client surface (the deploy gateway protocol of SPEC §7, the CLI login handoff of §8.3 and POST /__backyard/api/tokens) for testing the CLI and the MCP server without running the real server.
Index ¶
- Constants
- type Gateway
- func (g *Gateway) AddSite(name string, files map[string]string, updatedBy string)
- func (g *Gateway) AddToken(token string, u identity.User)
- func (g *Gateway) Count(method, pathSuffix string) int
- func (g *Gateway) GatewayURL() string
- func (g *Gateway) Meta(name string) (sites.Meta, bool)
- func (g *Gateway) Requests() []Request
- func (g *Gateway) SetFileRaw(site, path string, content []byte)
- func (g *Gateway) SiteFiles(name string) map[string]string
- func (g *Gateway) SiteURL(site string) string
- func (g *Gateway) TokenRequests() []TokenRequest
- func (g *Gateway) Uploads() int
- type Request
- type Site
- type TokenRequest
Constants ¶
const GatewayPath = "/__backyard/api/deploy"
GatewayPath is where the fake mounts the gateway (as the real server).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Gateway ¶
type Gateway struct {
Server *httptest.Server
// URL is the server root (hub URL).
URL string
// Info is returned by GET /info (PublicURL and GatewayURL are filled
// in by NewGateway).
Info deploy.Info
// Tokens maps valid bearer tokens to users.
Tokens map[string]identity.User
// Anonymous accepts requests without a token (as a guest).
Anonymous bool
// HTML makes every gateway route answer with an HTML login page, like
// an identity-aware proxy in front of the server.
HTML bool
// CLIToken is issued by /__backyard/auth/cli (with CLITokenExpiry).
CLIToken string
CLITokenExpiry time.Time
// MintedToken is returned by POST /__backyard/api/tokens.
MintedToken string
// contains filtered or unexported fields
}
Gateway is a fake Backyard server. Configure its exported fields before issuing requests; use Lock/Unlock (or the helpers) when reading state while requests may be in flight.
func NewGateway ¶
NewGateway starts a fake server; it is closed when the test ends.
func (*Gateway) AddSite ¶
AddSite stores a site with files (path → content), last deployed by updatedBy.
func (*Gateway) AddToken ¶
AddToken registers a valid bearer token (safe while requests are in flight).
func (*Gateway) GatewayURL ¶
GatewayURL returns the embedded gateway URL.
func (*Gateway) SetFileRaw ¶
SetFileRaw stores a file under any path (even an invalid one), to test client-side path validation.
func (*Gateway) TokenRequests ¶
func (g *Gateway) TokenRequests() []TokenRequest
TokenRequests returns the recorded token-mint requests.
type TokenRequest ¶
TokenRequest records a POST /__backyard/api/tokens call.