Documentation
¶
Overview ¶
Package fakes provides fake HTTP servers for acceptance testing.
Index ¶
- Constants
- type Artifact
- type CircleCI
- func (f *CircleCI) AddComponent(component DeployComponent)
- func (f *CircleCI) AddComponentVersion(version DeployComponentVersion)
- func (f *CircleCI) AddContext(orgSlug string, ctx Context)
- func (f *CircleCI) AddContextEnvVar(contextID string, envVar ContextEnvVar)
- func (f *CircleCI) AddContextRestriction(contextID string, restriction ContextRestriction)
- func (f *CircleCI) AddDecisionLog(ownerID, policyCtx string, log DecisionLog)
- func (f *CircleCI) AddDeployment(deployment Deployment)
- func (f *CircleCI) AddEnvVar(slug, name, value string, createdAt *time.Time)
- func (f *CircleCI) AddEnvironment(environment DeployEnvironment)
- func (f *CircleCI) AddFollowedProject(proj FollowedProject)
- func (f *CircleCI) AddGitHubAppRepository(orgID string, repo GitHubAppRepo)
- func (f *CircleCI) AddIOSBundle(orgID string, bundle IOSSigningConfig)
- func (f *CircleCI) AddIOSCert(orgID string, cert IOSCert)
- func (f *CircleCI) AddJobArtifacts(slug string, jobNumber int64, artifactItems ...any)
- func (f *CircleCI) AddJobArtifactsV3(jobID string, items ...Artifact)
- func (f *CircleCI) AddJobResourceUsage(id string, usage ResourceUsage)
- func (f *CircleCI) AddJobStderr(id string, execution, stepNum int, content []byte)
- func (f *CircleCI) AddJobStdout(id string, execution, stepNum int, content []byte)
- func (f *CircleCI) AddJobStdoutCondensed(id string, execution, stepNum int, content []byte)
- func (f *CircleCI) AddJobTests(id string, tests ...TestResult)
- func (f *CircleCI) AddJobV3(job JobV3)
- func (f *CircleCI) AddNamespace(id, name string)
- func (f *CircleCI) AddOrbCategory(id, name string)
- func (f *CircleCI) AddOrbPackage(id, nsID, nsName, orbName string, isPrivate, isListed bool)
- func (f *CircleCI) AddOrbVersion(id, orbID, orbName, version, source, createdAt string)
- func (f *CircleCI) AddOrg(id, slug, name, vcsType string)
- func (f *CircleCI) AddPipelineDefinition(projectID string, def any)
- func (f *CircleCI) AddPolicyBundle(ownerID, policyCtx string, bundle map[string]string)
- func (f *CircleCI) AddProjectBySlug(slug, id, name, orgID string)
- func (f *CircleCI) AddProjectInfo(slug string, info ProjectInfo)
- func (f *CircleCI) AddProjectRuns(slug string, runs ...PipelineV2)
- func (f *CircleCI) AddProjectV3(id string, project any)
- func (f *CircleCI) AddResourceClass(rc ResourceClass)
- func (f *CircleCI) AddRun(id string, run PipelineV2)
- func (f *CircleCI) AddRunV3(id, projectID string, run RunV3)
- func (f *CircleCI) AddRunWorkflowsV3(runID string, workflows ...WorkflowV3)
- func (f *CircleCI) AddRunnerInstance(instance RunnerInstance)
- func (f *CircleCI) AddRunnerToken(resourceClass string, token RunnerToken)
- func (f *CircleCI) AddStaticFile(path, content string)
- func (f *CircleCI) AddTrigger(projectID, pipelineDefinitionID string, trigger any)
- func (f *CircleCI) AddWorkflowJobsV3(workflowID string, jobs ...JobV3)
- func (f *CircleCI) AddWorkflowV3(id string, workflow WorkflowV3)
- func (f *CircleCI) AllowToken(token string)
- func (f *CircleCI) DeletedIOSBundle(id string) bool
- func (f *CircleCI) DeletedIOSCert(certID string) bool
- func (f *CircleCI) LastCompileOwnerID() string
- func (f *CircleCI) LastPARRequest() url.Values
- func (f *CircleCI) RequireTokens(tokens ...string)
- func (f *CircleCI) RerunWasFromFailed(workflowID string) bool
- func (f *CircleCI) SetCancelResponse(workflowID string, status int)
- func (f *CircleCI) SetCollaborations(collabs ...Collaboration)
- func (f *CircleCI) SetCompileResponse(valid bool, outputYAML string, errors ...string)
- func (f *CircleCI) SetCreateOrgResponse(resp any)
- func (f *CircleCI) SetCreatePipelineDefinitionResponse(projectID string, resp any)
- func (f *CircleCI) SetCreateProjectConflict()
- func (f *CircleCI) SetCreateProjectResponse(resp any)
- func (f *CircleCI) SetCreateTriggerResponse(projectID, pipelineDefinitionID string, resp any)
- func (f *CircleCI) SetDLCPurgeStatus(projectID string, status int)
- func (f *CircleCI) SetDecisionResult(ownerID, policyCtx string, result DecisionResult)
- func (f *CircleCI) SetDeploySettings(settings DeploySettings)
- func (f *CircleCI) SetGitHubAppInstallResponse(resp any)
- func (f *CircleCI) SetLatestRelease(tool, version string, publishedAt time.Time)
- func (f *CircleCI) SetMe(me User)
- func (f *CircleCI) SetOAuthTokenError(status int, resp any)
- func (f *CircleCI) SetOAuthTokenResponse(resp any)
- func (f *CircleCI) SetOrbAddCategoryStatus(status int)
- func (f *CircleCI) SetOrbValidationResponse(yaml string, valid bool, errors []string, outputYAML string)
- func (f *CircleCI) SetOrgSettings(orgUUID string, settings any)
- func (f *CircleCI) SetPipelineCancelResponse(pipelineID string, status int)
- func (f *CircleCI) SetPolicyEnabled(ownerID, policyCtx string, enabled bool)
- func (f *CircleCI) SetProjectSettings(projectID string, settings any)
- func (f *CircleCI) SetProviderConnected(orgID, provider string, connected bool)
- func (f *CircleCI) SetReleaseStatus(status int)
- func (f *CircleCI) SetRerunNewWorkflowID(workflowID, newID string)
- func (f *CircleCI) SetRerunResponse(workflowID string, status int)
- func (f *CircleCI) SetRollback(result RollbackResult)
- func (f *CircleCI) SetRunWorkflowsV3NotFound(runID string)
- func (f *CircleCI) SetRunnerTokenCreateResponse(status int, body any)
- func (f *CircleCI) SetTriggerPipelineRunResponse(slug string, resp any)
- func (f *CircleCI) SetTriggerPipelineRunSkipped(slug, message string)
- func (f *CircleCI) SetTriggerResponse(slug string, resp any)
- func (f *CircleCI) SetUserRuns(runs ...RunV3)
- func (f *CircleCI) URL() string
- type Collaboration
- type Context
- type ContextEnvVar
- type ContextRestriction
- type DecisionLog
- type DecisionResult
- type DeployComponent
- type DeployComponentVersion
- type DeployEnvironment
- type DeploySettings
- type Deployment
- type EnvVar
- type ExtensionMeta
- type ExtensionRegistry
- type FollowedProject
- type GitHubAppRepo
- type IOSCert
- type IOSProfile
- type IOSSigningConfig
- type JobStep
- type JobV3
- type Namespace
- type Orb
- type OrbCategory
- type OrbVersion
- type Org
- type PipelineV2
- type ProjectInfo
- type ProjectV3
- type ResourceClass
- type ResourceUsage
- type ResourceUsageExecution
- type RollbackResult
- type RunError
- type RunV3
- type RunnerInstance
- type RunnerToken
- type TestResult
- type User
- type VCSInfo
- type WorkflowV3
Constants ¶
const DefaultRerunWorkflowID = "11111111-1111-4111-8111-111111111111"
DefaultRerunWorkflowID is the id of the workflow a rerun creates, unless a test overrides it with SetRerunNewWorkflowID.
It is deliberately not the id being rerun. A rerun creates a *new* workflow, and echoing the old id back would let a caller that mistakenly reports the id it was given pass its tests.
const DefaultToken = "test-token"
DefaultToken is the bearer token the fake accepts when NewCircleCI is called without an explicit token list. It matches the token acceptance tests inject via env.Token, so the common case needs no wiring.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Artifact ¶ added in v1.0.47692
Artifact is a stored job artifact served by GET /api/v3/jobs/<id>/artifacts. Execution is the parallel-run index (0-based) the artifact came from.
type CircleCI ¶
type CircleCI struct {
*httprecorder.RequestRecorder
// ExtraHeaders are added to every response via middleware. Use to inject
// Deprecation/Sunset headers without changing individual handler logic.
ExtraHeaders http.Header
// contains filtered or unexported fields
}
CircleCI is a fake CircleCI API server.
func NewCircleCI ¶
NewCircleCI starts a fake CircleCI API server and registers t.Cleanup to close it.
The fake enforces authentication: every request to a non-exempt route must carry Authorization: Bearer <token> with a token in the accepted set, or it is rejected with 401. The accepted set defaults to DefaultToken; pass one or more tokens to override it, or adjust it later with RequireTokens/AllowToken. The login/pre-auth routes (/oauth/*, /artifacts/*, config compile, tool releases) are exempt — see authExempt.
func (*CircleCI) AddComponent ¶ added in v1.0.47471
func (f *CircleCI) AddComponent(component DeployComponent)
AddComponent registers a deploy component, listed for requests whose filter[org_id] matches its OrgID (and filter[project_id] its ProjectID) and fetched by its ID.
func (*CircleCI) AddComponentVersion ¶ added in v1.0.47471
func (f *CircleCI) AddComponentVersion(version DeployComponentVersion)
AddComponentVersion registers a version for a deploy component, listed under its ComponentID and (optionally) narrowed by filter[environment_id].
func (*CircleCI) AddContext ¶
AddContext registers a context served by GET /api/v2/context/{id} and indexed by org slug for list responses.
func (*CircleCI) AddContextEnvVar ¶
func (f *CircleCI) AddContextEnvVar(contextID string, envVar ContextEnvVar)
AddContextEnvVar registers an environment variable for a context.
func (*CircleCI) AddContextRestriction ¶
func (f *CircleCI) AddContextRestriction(contextID string, restriction ContextRestriction)
AddContextRestriction registers a restriction for a context.
func (*CircleCI) AddDecisionLog ¶
func (f *CircleCI) AddDecisionLog(ownerID, policyCtx string, log DecisionLog)
func (*CircleCI) AddDeployment ¶ added in v1.0.47331
func (f *CircleCI) AddDeployment(deployment Deployment)
AddDeployment registers a deployment, returned by GET /api/v3/deploy/deployments for requests whose filter[project_id] matches its ProjectID.
func (*CircleCI) AddEnvVar ¶
AddEnvVar registers an env var for a project. slug should be in "vcs/org/repo" form.
func (*CircleCI) AddEnvironment ¶ added in v1.0.47471
func (f *CircleCI) AddEnvironment(environment DeployEnvironment)
AddEnvironment registers a deploy environment, listed for requests whose filter[org_id] matches its OrgID and fetched by its ID.
func (*CircleCI) AddFollowedProject ¶
func (f *CircleCI) AddFollowedProject(proj FollowedProject)
AddFollowedProject registers a project returned by GET /api/v1.1/projects.
func (*CircleCI) AddGitHubAppRepository ¶
func (f *CircleCI) AddGitHubAppRepository(orgID string, repo GitHubAppRepo)
AddGitHubAppRepository registers a repository returned by GET /api/v2/github-app/organization/{orgID}/repositories.
func (*CircleCI) AddIOSBundle ¶
func (f *CircleCI) AddIOSBundle(orgID string, bundle IOSSigningConfig)
AddIOSBundle registers an iOS signing config for an org, returned by GET /api/v3/signing/configs?filter[org_id]=<orgID>.
func (*CircleCI) AddIOSCert ¶
AddIOSCert registers an iOS certificate for an org, returned by GET /api/v3/signing/certificates?filter[org_id]=<orgID>.
func (*CircleCI) AddJobArtifacts ¶
AddJobArtifacts registers artifact responses for a job. slug should be in "vcs/org/repo" form; jobNumber is the integer job number.
func (*CircleCI) AddJobArtifactsV3 ¶
AddJobArtifactsV3 registers V3 artifacts for a job UUID.
func (*CircleCI) AddJobResourceUsage ¶ added in v1.0.48122
func (f *CircleCI) AddJobResourceUsage(id string, usage ResourceUsage)
AddJobResourceUsage registers a job's sampled resource usage, served by GET /api/v3/jobs/<id>/resource-usage. A job with none registered returns 404, matching the real endpoint's answer for a job that never ran an executor.
func (*CircleCI) AddJobStderr ¶
AddJobStderr registers plain-text stderr for a step, served at GET /api/v3/jobs/<id>/stderr?filter[execution]=<execution>&filter[step_num]=<stepNum>.
func (*CircleCI) AddJobStdout ¶
AddJobStdout registers plain-text stdout for a step, served at GET /api/v3/jobs/<id>/stdout?filter[execution]=<execution>&filter[step_num]=<stepNum>.
func (*CircleCI) AddJobStdoutCondensed ¶
AddJobStdoutCondensed registers the condensed stdout for a step, served at GET /api/v3/jobs/<id>/stdout/condensed?filter[execution]=<execution>&filter[step_num]=<stepNum>.
func (*CircleCI) AddJobTests ¶
func (f *CircleCI) AddJobTests(id string, tests ...TestResult)
AddJobTests registers test-result records for a job UUID, served as newline-delimited JSON (JSONL) at GET /api/v3/jobs/<id>/tests.
func (*CircleCI) AddJobV3 ¶
AddJobV3 registers a job's detail, served by GET /api/v3/jobs/<id> keyed on the job's ID.
func (*CircleCI) AddNamespace ¶
AddNamespace registers a namespace for REST API queries. id and name form the namespace record returned by the /api/v3/namespaces endpoints.
func (*CircleCI) AddOrbCategory ¶
AddOrbCategory registers an orb category in the fake server.
func (*CircleCI) AddOrbPackage ¶
AddOrbPackage registers an orb package in the fake server.
func (*CircleCI) AddOrbVersion ¶
AddOrbVersion registers an orb version in the fake server. createdAt can be empty (will default to a fixed timestamp).
func (*CircleCI) AddPipelineDefinition ¶
AddPipelineDefinition registers a pipeline entity for a project, returned by GET /api/v3/pipelines?filter[project_id]=. def is a v3 data entity ({id, attributes, references}); the fake supplies the collection envelope.
func (*CircleCI) AddPolicyBundle ¶
AddPolicyBundle registers a policy bundle for the given owner and context.
func (*CircleCI) AddProjectBySlug ¶
AddProjectBySlug registers a project resolved by GET /api/v3/projects?filter[slug]=<slug>, returning its UUID, name, and org UUID.
func (*CircleCI) AddProjectInfo ¶
func (f *CircleCI) AddProjectInfo(slug string, info ProjectInfo)
AddProjectInfo registers a project info response for GET /api/v2/project/<slug>. slug should be in "vcs/org/repo" form.
func (*CircleCI) AddProjectRuns ¶
func (f *CircleCI) AddProjectRuns(slug string, runs ...PipelineV2)
AddProjectRuns registers runs for GET /api/v2/project/<slug>/pipeline. slug should be in "vcs/org/repo" form, e.g. "gh/myorg/myrepo".
func (*CircleCI) AddProjectV3 ¶
AddProjectV3 registers a project returned by GET /api/v3/projects/<id>, keyed by the project's UUID. The response is wrapped as {"data": project}.
func (*CircleCI) AddResourceClass ¶
func (f *CircleCI) AddResourceClass(rc ResourceClass)
AddResourceClass registers a runner resource class.
func (*CircleCI) AddRun ¶
func (f *CircleCI) AddRun(id string, run PipelineV2)
AddRun registers a run response for GET /api/v2/pipeline/<id>.
func (*CircleCI) AddRunV3 ¶
AddRunV3 registers a run served by GET /api/v3/runs/<id> and included in the search results for its project.
func (*CircleCI) AddRunWorkflowsV3 ¶
func (f *CircleCI) AddRunWorkflowsV3(runID string, workflows ...WorkflowV3)
AddRunWorkflowsV3 registers the workflows a run lists.
func (*CircleCI) AddRunnerInstance ¶
func (f *CircleCI) AddRunnerInstance(instance RunnerInstance)
AddRunnerInstance adds a runner instance to the fake server's list.
func (*CircleCI) AddRunnerToken ¶
func (f *CircleCI) AddRunnerToken(resourceClass string, token RunnerToken)
AddRunnerToken adds a token to the fake server for the given resource class.
func (*CircleCI) AddStaticFile ¶
AddStaticFile registers a path that serves static content for artifact download tests. Must be called before any requests are made to the server (i.e. before RunCLI). The path should be relative, e.g. "/artifacts/foo.html".
func (*CircleCI) AddTrigger ¶
AddTrigger registers a trigger entity returned by GET /api/v3/triggers when filtered by this project and pipeline.
func (*CircleCI) AddWorkflowJobsV3 ¶
AddWorkflowJobsV3 registers the jobs a workflow lists.
func (*CircleCI) AddWorkflowV3 ¶
func (f *CircleCI) AddWorkflowV3(id string, workflow WorkflowV3)
AddWorkflowV3 registers a workflow served by GET /api/v3/workflows/<id>.
func (*CircleCI) AllowToken ¶ added in v1.0.47653
AllowToken adds a token to the accepted-token set without disturbing the tokens already there. The OAuth token endpoint calls this for every token it mints, so a login flow's follow-up authenticated calls are accepted.
func (*CircleCI) DeletedIOSBundle ¶
DeletedIOSBundle reports whether the given bundle ID was deleted.
func (*CircleCI) DeletedIOSCert ¶
DeletedIOSCert reports whether the given cert ID was deleted.
func (*CircleCI) LastCompileOwnerID ¶
LastCompileOwnerID returns the owning org UUID sent on the most recent compile request (empty if none yet). Tests use it to assert that --org resolved to the expected organization UUID.
func (*CircleCI) LastPARRequest ¶
LastPARRequest returns the form parameters of the most recent POST /oauth/par (RFC 9126), or nil if none has been received. Acceptance tests use it to recover the redirect_uri and state, which no longer travel in the browser-facing authorize URL.
func (*CircleCI) RequireTokens ¶ added in v1.0.47653
RequireTokens replaces the accepted-token set, so a request must carry one of these as its Bearer token to reach any non-exempt route. Use it to pin the exact token a test expects, or to exercise the 401 path with a token the fake will reject.
func (*CircleCI) RerunWasFromFailed ¶
RerunWasFromFailed reports whether the rerun request for workflowID actually set is_from_failed, as decoded from the wire.
Assert on this rather than on the raw request body: a body comparison passes as long as client and fake agree, which is how sending the v2 field name to a v3 endpoint went unnoticed. This reports what the *endpoint* would have acted on, so a wrong field name reads as false.
func (*CircleCI) SetCancelResponse ¶
SetCancelResponse sets the HTTP status code returned for POST /api/v3/workflows/<id>/cancel. Use http.StatusAccepted (202) for success.
func (*CircleCI) SetCollaborations ¶
func (f *CircleCI) SetCollaborations(collabs ...Collaboration)
SetCollaborations sets the response for GET /api/v2/me/collaborations.
func (*CircleCI) SetCompileResponse ¶
SetCompileResponse configures what the compile route returns. Pass valid=false and one or more error messages to simulate a compilation failure.
func (*CircleCI) SetCreateOrgResponse ¶
SetCreateOrgResponse registers the response body returned when POST /api/v2/organization is called. Pass nil to simulate a 422 error.
func (*CircleCI) SetCreatePipelineDefinitionResponse ¶
SetCreatePipelineDefinitionResponse registers the entity returned when POST /api/v3/pipelines is called with this project in its references. Pass nil to simulate a 404.
func (*CircleCI) SetCreateProjectConflict ¶
func (f *CircleCI) SetCreateProjectConflict()
SetCreateProjectConflict makes POST /api/v2/organization/{vcs}/{org}/project answer 409, as the real API does when the organization already has a project with that name.
func (*CircleCI) SetCreateProjectResponse ¶
SetCreateProjectResponse registers the response body returned when POST /api/v2/organization/{vcs}/{org}/project is called. Pass nil to simulate a 422 error.
func (*CircleCI) SetCreateTriggerResponse ¶
SetCreateTriggerResponse registers the entity returned when POST /api/v3/triggers is called for this project and pipeline. Pass nil to simulate a 404.
func (*CircleCI) SetDLCPurgeStatus ¶
SetDLCPurgeStatus sets the HTTP status returned for DELETE /private/output/project/{id}/dlc. Default is 204 (success). Use 410 to simulate the gone/deprecated response.
func (*CircleCI) SetDecisionResult ¶
func (f *CircleCI) SetDecisionResult(ownerID, policyCtx string, result DecisionResult)
SetDecisionResult sets the response returned by MakeDecision for the given owner and context.
func (*CircleCI) SetDeploySettings ¶ added in v1.0.47471
func (f *CircleCI) SetDeploySettings(settings DeploySettings)
SetDeploySettings registers deploy settings for a project.
func (*CircleCI) SetGitHubAppInstallResponse ¶
SetGitHubAppInstallResponse registers the body returned by POST /api/v2/github-app/install.
func (*CircleCI) SetLatestRelease ¶ added in v1.0.47519
SetLatestRelease registers the release returned by GET /api/v3/tool/releases for the given tool. Clears any previously set non-200 status.
func (*CircleCI) SetMe ¶
SetMe sets the authenticated user returned by the users?filter[user_id]=me endpoint. When unset, that endpoint answers 401.
func (*CircleCI) SetOAuthTokenError ¶
SetOAuthTokenError configures POST /oauth/token to return the given status and JSON body. Use for testing token-exchange failure paths.
func (*CircleCI) SetOAuthTokenResponse ¶
SetOAuthTokenResponse sets the response body for POST /oauth/token.
func (*CircleCI) SetOrbAddCategoryStatus ¶
SetOrbAddCategoryStatus makes every POST /api/v3/orb/packages/<id>/add-category fail with the given status, carrying the message the real registry returns when an orb is already at its category limit.
func (*CircleCI) SetOrbValidationResponse ¶
func (f *CircleCI) SetOrbValidationResponse(yaml string, valid bool, errors []string, outputYAML string)
SetOrbValidationResponse configures the validate/process endpoints to return the given result when the request YAML matches yaml. Pass "" for yaml to match any request.
func (*CircleCI) SetOrgSettings ¶
SetOrgSettings registers advanced settings for GET /api/v3/orgs/:id/settings. orgUUID should be the org UUID string.
func (*CircleCI) SetPipelineCancelResponse ¶
SetPipelineCancelResponse sets the HTTP status code returned for POST /api/v2/pipeline/<id>/cancel. Use http.StatusAccepted (202) for success.
func (*CircleCI) SetPolicyEnabled ¶
SetPolicyEnabled sets the policy enforcement enabled flag for the given owner and context.
func (*CircleCI) SetProjectSettings ¶
SetProjectSettings registers advanced settings for GET /api/v3/projects/:id/settings. projectID should be the project UUID string.
func (*CircleCI) SetProviderConnected ¶ added in v1.0.48454
SetProviderConnected controls whether GET /api/v3/provider/connections lists a connection for the org and provider. An org with no connection for a provider reads as not connected, which is how the GitHub App install check spells "not installed".
func (*CircleCI) SetReleaseStatus ¶ added in v1.0.47519
SetReleaseStatus makes GET /api/v3/tool/releases answer with the given HTTP status (e.g. 503 or 400) instead of a 200.
func (*CircleCI) SetRerunNewWorkflowID ¶
SetRerunNewWorkflowID sets the id that rerunning workflowID reports, for a test that needs to distinguish several reruns.
func (*CircleCI) SetRerunResponse ¶
SetRerunResponse sets the HTTP status code returned for POST /api/v2/workflow/<id>/rerun. Use http.StatusAccepted (202) for success.
func (*CircleCI) SetRollback ¶ added in v1.0.48275
func (f *CircleCI) SetRollback(result RollbackResult)
SetRollback registers the result of POST /api/v3/projects/{id}/rollback. Until it is called the route answers 404, matching a project with no rollback.
func (*CircleCI) SetRunWorkflowsV3NotFound ¶
SetRunWorkflowsV3NotFound makes GET /api/v3/workflows?filter[run_id]=<runID> return 404 for the given run, mirroring the real API for runs whose workflows have not materialised.
func (*CircleCI) SetRunnerTokenCreateResponse ¶ added in v1.0.47122
SetRunnerTokenCreateResponse overrides the response to POST /runner/token, which otherwise answers 201 with a token whose value is "fake-runner-token-value". Use it to force a failure, or a 201 whose payload omits or lengthens the token value. A nil body sends a generic error message.
func (*CircleCI) SetTriggerPipelineRunResponse ¶
SetTriggerPipelineRunResponse registers the response body returned when POST /api/v2/project/<slug>/pipeline/run is called with a 201 status. slug should be in "vcs/org/repo" form.
func (*CircleCI) SetTriggerPipelineRunSkipped ¶
SetTriggerPipelineRunSkipped registers a "not triggered" response (200) for POST /api/v2/project/<slug>/pipeline/run.
func (*CircleCI) SetTriggerResponse ¶
SetTriggerResponse registers the response body returned when POST /api/v2/project/<slug>/pipeline is called. slug should be in "vcs/org/repo" form.
func (*CircleCI) SetUserRuns ¶
SetUserRuns registers the runs returned by GET /api/v3/runs?filter[user_id]=me (i.e. "circleci my runs").
type Collaboration ¶ added in v1.0.47715
Collaboration is an org the authenticated user collaborates on, served by GET /api/v2/me/collaborations.
type Context ¶ added in v1.0.47715
Context is a stored context served by the context list/get/create endpoints.
type ContextEnvVar ¶ added in v1.0.47715
type ContextEnvVar struct {
Variable string
TruncatedValue string
ContextID string
CreatedAt string
UpdatedAt string
}
ContextEnvVar is a stored context environment variable. TruncatedValue is the masked value the list/get surface; a freshly-set variable has none, so it renders only when set.
type ContextRestriction ¶ added in v1.0.47715
type ContextRestriction struct {
ContextID string
ID string
RestrictionType string
RestrictionValue string
Name string
}
ContextRestriction is a stored context restriction. ContextID renders only when set — the create response omits it, matching the real API.
type DecisionLog ¶ added in v1.0.47735
DecisionLog is a stored policy decision-log entry served by the decision log list/get endpoints.
type DecisionResult ¶ added in v1.0.47735
type DecisionResult struct {
Status string
}
DecisionResult is the decision returned by the make-decision endpoint.
type DeployComponent ¶ added in v1.0.47653
DeployComponent is a stored deploy component served by the component list/get endpoints. OrgID is the list filter key; ProjectID narrows the list.
type DeployComponentVersion ¶ added in v1.0.47653
type DeployComponentVersion struct {
ID string
ComponentID string
EnvironmentID string
Name string
CreatedAt string
}
DeployComponentVersion is a stored version served by the component-versions endpoint. ComponentID is the list key; EnvironmentID optionally narrows it.
type DeployEnvironment ¶ added in v1.0.47653
DeployEnvironment is a stored deploy environment served by the environment list/get endpoints. OrgID is the list filter key.
type DeploySettings ¶ added in v1.0.47653
DeploySettings is a stored deploy settings entity for a project.
type Deployment ¶ added in v1.0.47653
type Deployment struct {
ID string
ProjectID string // list filter key; not rendered
ComponentID string
ComponentName string
EnvironmentID string
PipelineID string
WorkflowID string
Type string
Status string
FailureReason string
Version string // rendered as target_version.name
IsRollback bool
CreatedAt string
EndedAt string
}
Deployment is a stored deploy served by GET /api/v3/deploy/deployments, filtered by ProjectID. Add deployments newest-first — the endpoint returns them in insertion order. Optional string fields (FailureReason, EndedAt, PipelineID, WorkflowID) are omitted from the wire entity when empty, matching the real API.
type EnvVar ¶ added in v1.0.47715
EnvVar is a stored project environment variable served by the project env-var list/set endpoints. CreatedAt is a pointer so a variable with no timestamp renders created_at as null, matching the real API.
type ExtensionMeta ¶
type ExtensionRegistry ¶
type ExtensionRegistry struct {
RequestRecorder *httprecorder.RequestRecorder
// contains filtered or unexported fields
}
func NewExtensionRegistry ¶
func NewExtensionRegistry(t *testing.T) *ExtensionRegistry
func (*ExtensionRegistry) Manifest ¶
func (e *ExtensionRegistry) Manifest(binaryName string) extension.Manifest
func (*ExtensionRegistry) URL ¶
func (e *ExtensionRegistry) URL() string
func (*ExtensionRegistry) WithExtension ¶
func (e *ExtensionRegistry) WithExtension(t *testing.T, ext extension.Manifest, meta ExtensionMeta) *ExtensionRegistry
type FollowedProject ¶ added in v1.0.47715
type FollowedProject struct {
Slug string
Username string
Reponame string
VCSType string
Name string
}
FollowedProject is a stored project served by GET /api/v1.1/projects.
type GitHubAppRepo ¶ added in v1.0.47735
type GitHubAppRepo struct {
ID int
RepoFullName string
RepoName string
Owner string
DefaultBranch string
Private bool
}
GitHubAppRepo is a stored repository the CircleCI GitHub App can access, served by the org repositories endpoint. DefaultBranch renders only when set.
type IOSCert ¶ added in v1.0.47715
IOSCert is a stored iOS signing certificate served by the signing certificate list endpoint and referenced by signing configs.
type IOSProfile ¶ added in v1.0.47993
IOSProfile holds the ID and file name of a provisioning profile for the remove-profile endpoint BundleID/ProfileType mirror the real server's replace-match key (bundle identifier + profile type embedded in the file, not the file name); the fake reads them from a stand-in content convention instead of a real plist parser (see fakeMobileProvisionContent in acceptance/certificate_test.go).
type IOSSigningConfig ¶ added in v1.0.47715
type IOSSigningConfig struct {
ID string
Name string
CertID string
CertFileName string
CertType string
ProvisioningProfiles []IOSProfile
}
IOSSigningConfig is a stored iOS signing config (bundle) served by the signing config list endpoint. CertID links it to the IOSCert it uses (the cert-in-use check on delete); CertFileName/CertType are the certificate reference echoed on the wire.
type JobStep ¶ added in v1.0.47692
type JobStep struct {
Name string
Type string
Num int
Phase string
Outcome string
ExitCode *int
Command string
StartedAt string
EndedAt string
}
JobStep is a single step within a JobV3 execution. ExitCode is a pointer so a step that never ran a command (spin-up, checkout) omits it, distinct from an explicit exit code of 0; Command is omitted when empty.
type JobV3 ¶ added in v1.0.47692
type JobV3 struct {
ID string
Name string
Type string
Phase string
Outcome string
StartedAt string
EndedAt string
ProjectID string
WorkflowID string
PipelineID string
UserID string
Executions [][]JobStep // parallel_executions, one inner slice of steps per execution
}
JobV3 is a stored job served by both the workflow-jobs list (GET /api/v3/workflows/{id}/jobs) and the job-detail endpoint (GET /api/v3/jobs/{id}). The list exposes the summary attributes and references; detail adds the nested parallel executions. Optional fields (Outcome, StartedAt, EndedAt, the reference ids) are omitted from the wire entity when empty, and Executions is omitted when nil — matching how the real API reports a queued job that has not run yet.
type Namespace ¶ added in v1.0.47715
Namespace is a stored namespace served by the REST namespace endpoints.
type Orb ¶ added in v1.0.47761
type Orb struct {
ID string
Name string // full "namespace/orb"
NsID string
NsName string
IsPrivate bool
IsListed bool
CreatedAt string
}
Orb is a stored orb package served by the orb package endpoints. is_listed, orb_versions and orb_categories are derived at render time from the unlisted set, version list and category membership respectively.
type OrbCategory ¶ added in v1.0.47761
OrbCategory is a stored orb category.
type OrbVersion ¶ added in v1.0.47761
type OrbVersion struct {
ID string
OrbID string
OrbName string // full "namespace/orb"
Version string
Source string
CreatedAt string
}
OrbVersion is a stored orb version. Source is served only by the dedicated /source endpoint and by the version list — the get/create/promote responses strip it.
type Org ¶ added in v1.0.47692
Org is a stored organization resolved by GET /api/v3/orgs?filter[slug]=<slug>. The resolve endpoint surfaces only the id; Slug, Name and VCSType round out the record for completeness.
type PipelineV2 ¶ added in v1.0.47735
type PipelineV2 struct {
ID string
Number int
State string
ProjectSlug string
Branch string
Revision string
CreatedAt string
UpdatedAt string
}
PipelineV2 is a stored v2 pipeline served by the pipeline get/get-by-number and project pipeline-list endpoints. The structural fixture fields (trigger type, actor, repository URLs) are constant across tests and supplied by the renderer; only the fields below vary.
type ProjectInfo ¶ added in v1.0.47735
type ProjectInfo struct {
ID string
Slug string
Name string
OrganizationName string
OrganizationSlug string
OrganizationID string
VCSInfo *VCSInfo
}
ProjectInfo is a stored v1.1/v2 project record served by GET /api/v2/project/<slug>. Only ID and Slug are always present; the org fields and VCSInfo render only when set.
type ProjectV3 ¶ added in v1.0.47692
ProjectV3 is a stored project resolved by GET /api/v3/projects?filter[slug]=<slug>. The entity carries its UUID, name, and owning org UUID — enough for the CLI to map a slug to its project.
type ResourceClass ¶ added in v1.0.47715
ResourceClass is a stored runner resource class served by the runner resource-class list and create endpoints. Slug is the "resource_class" wire field (e.g. "my-org/linux-runner"); the list filters on its namespace prefix.
type ResourceUsage ¶ added in v1.0.48122
type ResourceUsage struct {
ClassName string
CPUCount float64
MemoryLimitBytes int64
Executions []ResourceUsageExecution
}
ResourceUsage is a job's stored resource usage, served by GET /api/v3/jobs/<id>/resource-usage. It is named for the endpoint rather than the resource class it carries, since ResourceClass is already taken by the runner fixtures.
type ResourceUsageExecution ¶ added in v1.0.48122
type ResourceUsageExecution struct {
Index int
IntervalMS int
CPUCores []float64
MemoryBytes []int64
NetworkRxBytes int64
NetworkTxBytes int64
}
ResourceUsageExecution is one parallel execution's usage series. Index is the execution index the entity reports; the caller sets it explicitly rather than relying on slice position, so a test can register a non-zero index on its own.
type RollbackResult ¶ added in v1.0.48275
RollbackResult is what POST /api/v3/projects/{id}/rollback reports. ID is the pipeline run or release-agent command carrying the rollback out and RollbackType ("pipeline" or "agent") says which. Set Status to return that status with a v3 error envelope instead of the entity, so a test can exercise a rejected or conflicting rollback.
type RunError ¶ added in v1.0.47692
RunError is a config/setup error attached to a run, surfaced by run get.
type RunV3 ¶ added in v1.0.47692
type RunV3 struct {
ID string
ProjectID string
UserID string
Phase string
CurrentOutcome string
CreatedAt string
Branch string
Tag string
Revision string
OriginRepoURL string
Errors []RunError
}
RunV3 is a stored run served by the run-detail, run-search, and my-runs endpoints. A run that resolved a revision renders a commit block; Tag, OriginRepoURL and Errors render only when set. CurrentOutcome is omitted when empty, matching a run that has not finished.
type RunnerInstance ¶ added in v1.0.47715
type RunnerInstance struct {
ResourceClass string
Hostname string
Name string
Version string
IP string
FirstConnected string
LastConnected string
LastUsed string
}
RunnerInstance is a stored runner instance served by the runner instance list, filtered by resource-class or namespace prefix.
type RunnerToken ¶ added in v1.0.47715
type RunnerToken struct {
ID string
ResourceClass string
Nickname string
CreatedAt string
Token string
}
RunnerToken is a stored runner token served by the runner token list and create endpoints. Token carries the secret value, which only the create response includes — it renders when set.
type TestResult ¶ added in v1.0.47692
type TestResult struct {
Classname string `json:"classname"`
Name string `json:"name"`
Result string `json:"result"`
RunTime float64 `json:"run_time"`
Message string `json:"message"`
}
TestResult is a stored test result served by the fake job-tests endpoint, which streams these as newline-delimited JSON (JSONL). The JSON tags match the wire fields the CLI decodes.
type User ¶ added in v1.0.47715
User is the authenticated user served by GET /api/v3/users?filter[user_id]=me. AvatarURL renders only when set.
type WorkflowV3 ¶ added in v1.0.47692
type WorkflowV3 struct {
ID string
Name string
RunID string
ProjectID string
UserID string
Phase string
Outcome string
CreatedAt string
EndedAt string
}
WorkflowV3 is a stored workflow served by the workflow-detail (GET /api/v3/workflows/{id}) and run-workflows list endpoints. An ended workflow reports outcome + ended_at; a still-running one reports current_outcome and no ended_at instead — mirroring the real API.