fakes

package
v1.0.37475-pre Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package fakes provides fake HTTP servers for acceptance testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CircleCI

type CircleCI struct {
	// contains filtered or unexported fields
}

CircleCI is a fake CircleCI API server.

func NewCircleCI

func NewCircleCI(t *testing.T) *CircleCI

NewCircleCI starts a fake CircleCI API server and registers t.Cleanup to close it.

func (*CircleCI) AddContext

func (f *CircleCI) AddContext(orgSlug string, ctx any)

AddContext registers a context object for GET /api/v2/context/{id}. ctx should be a map with at least "id", "name", and "created_at" fields. It is also indexed by org slug for list responses.

func (*CircleCI) AddContextEnvVar

func (f *CircleCI) AddContextEnvVar(contextID string, envVar any)

AddContextEnvVar registers an environment variable for a context.

func (*CircleCI) AddContextRestriction

func (f *CircleCI) AddContextRestriction(contextID string, restriction any)

AddContextRestriction registers a restriction for a context.

func (*CircleCI) AddDeploy

func (f *CircleCI) AddDeploy(projectID string, deploy any)

AddDeploy registers a deploy for a project, returned by GET /api/v2/deploy/projects/{project_id}/releases.

func (*CircleCI) AddEnvVar

func (f *CircleCI) AddEnvVar(slug, name, value string, createdAt *time.Time)

AddEnvVar registers an env var for a project. slug should be in "vcs/org/repo" form.

func (*CircleCI) AddFollowedProject

func (f *CircleCI) AddFollowedProject(proj any)

AddFollowedProject registers a project returned by GET /api/v1.1/projects. proj should be a map or struct with at least "slug", "username", and "reponame" fields.

func (*CircleCI) AddIOSBundle

func (f *CircleCI) AddIOSBundle(orgID string, bundle any)

AddIOSBundle registers an iOS signing bundle for an org, returned by GET /api/v2/signing-configs?org-id=<orgID>.

func (*CircleCI) AddIOSCert

func (f *CircleCI) AddIOSCert(orgID string, cert any)

AddIOSCert registers an iOS certificate for an org, returned by GET /api/v2/certificates?org-id=<orgID>.

func (*CircleCI) AddJob

func (f *CircleCI) AddJob(slug string, jobNumber int64, job any)

AddJob registers a job detail response for GET /api/v2/project/<slug>/job/<number>. slug should be in "vcs/org/repo" form; jobNumber is the integer job number.

func (*CircleCI) AddJobArtifacts

func (f *CircleCI) AddJobArtifacts(slug string, jobNumber int64, artifactItems ...any)

AddJobArtifacts registers artifact responses for a job. slug should be in "vcs/org/repo" form; jobNumber is the integer job number.

func (*CircleCI) AddJobV1

func (f *CircleCI) AddJobV1(slug string, jobNumber int64, job any)

AddJobV1 registers a v1.1 job detail response. Use this alongside AddJob (with a job body that has no steps) to exercise the v2→v1.1 fallback path. slug should be in the v1.1 form, e.g. "github/org/repo".

func (*CircleCI) AddNamespace

func (f *CircleCI) AddNamespace(id, name string)

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

func (f *CircleCI) AddOrbCategory(id, name string)

AddOrbCategory registers an orb category in the fake server.

func (*CircleCI) AddOrbPackage

func (f *CircleCI) AddOrbPackage(id, nsID, nsName, orbName string, isPrivate, isListed bool)

AddOrbPackage registers an orb package in the fake server.

func (*CircleCI) AddOrbVersion

func (f *CircleCI) AddOrbVersion(id, orbID, orbName, version, source, createdAt string)

AddOrbVersion registers an orb version in the fake server. createdAt can be empty (will default to a fixed timestamp).

func (*CircleCI) AddPipelineDefinition

func (f *CircleCI) AddPipelineDefinition(projectID string, def any)

AddPipelineDefinition registers a pipeline definition for a project, returned by GET /api/v2/projects/{projectID}/pipeline-definitions.

func (*CircleCI) AddProjectInfo

func (f *CircleCI) AddProjectInfo(slug string, info any)

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 ...any)

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) AddResourceClass

func (f *CircleCI) AddResourceClass(rc any)

AddResourceClass adds a resource class to the fake server's list.

func (*CircleCI) AddRun

func (f *CircleCI) AddRun(id string, run any)

AddRun registers a run response for GET /api/v2/pipeline/<id>.

func (*CircleCI) AddRunWorkflows

func (f *CircleCI) AddRunWorkflows(runID string, workflows ...any)

AddRunWorkflows registers workflow responses for a run.

func (*CircleCI) AddRunnerInstance

func (f *CircleCI) AddRunnerInstance(instance any)

AddRunnerInstance adds a runner instance to the fake server's list.

func (*CircleCI) AddRunnerToken

func (f *CircleCI) AddRunnerToken(resourceClass string, token any)

AddRunnerToken adds a token to the fake server for the given resource class.

func (*CircleCI) AddStaticFile

func (f *CircleCI) AddStaticFile(path, content string)

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) AddStepOutput

func (f *CircleCI) AddStepOutput(path, content string)

AddStepOutput registers JSON log-line content served at the given path, e.g. "/output/job/99/step/0". The path must match the output_url set on the fake job's step actions (relative to the fake server URL).

func (*CircleCI) AddTrigger

func (f *CircleCI) AddTrigger(projectID, pipelineDefinitionID string, trigger any)

AddTrigger registers a trigger returned by GET /api/v2/projects/{projectID}/pipeline-definitions/{pipelineDefinitionID}/triggers.

func (*CircleCI) AddWorkflowDetail

func (f *CircleCI) AddWorkflowDetail(id string, detail any)

AddWorkflowDetail registers a workflow detail response for GET /api/v2/workflow/<id>.

func (*CircleCI) AddWorkflowJobs

func (f *CircleCI) AddWorkflowJobs(workflowID string, jobs ...any)

AddWorkflowJobs registers job responses for a workflow.

func (*CircleCI) DeletedIOSBundle

func (f *CircleCI) DeletedIOSBundle(id string) bool

DeletedIOSBundle reports whether the given bundle ID was deleted.

func (*CircleCI) DeletedIOSCert

func (f *CircleCI) DeletedIOSCert(certID string) bool

DeletedIOSCert reports whether the given cert ID was deleted.

func (*CircleCI) SetCancelResponse

func (f *CircleCI) SetCancelResponse(workflowID string, status int)

SetCancelResponse sets the HTTP status code returned for POST /api/v2/workflow/<id>/cancel. Use http.StatusAccepted (202) for success.

func (*CircleCI) SetCreatePipelineDefinitionResponse

func (f *CircleCI) SetCreatePipelineDefinitionResponse(projectID string, resp any)

SetCreatePipelineDefinitionResponse registers the response body returned when POST /api/v2/projects/{projectID}/pipeline-definitions is called. Pass nil to simulate a 404.

func (*CircleCI) SetCreateTriggerResponse

func (f *CircleCI) SetCreateTriggerResponse(projectID, pipelineDefinitionID string, resp any)

SetCreateTriggerResponse registers the response body returned when POST /api/v2/projects/{projectID}/pipeline-definitions/{pipelineDefinitionID}/triggers is called. Pass nil to simulate a 404.

func (*CircleCI) SetMe

func (f *CircleCI) SetMe(me any)

SetMe sets the response body for GET /api/v2/me.

func (*CircleCI) SetOAuthTokenError

func (f *CircleCI) SetOAuthTokenError(status int, resp any)

SetOAuthTokenError configures POST /oauth/token to return the given status and JSON body. Use for testing token-exchange failure paths.

func (*CircleCI) SetOAuthTokenResponse

func (f *CircleCI) SetOAuthTokenResponse(resp any)

SetOAuthTokenResponse sets the response body for POST /oauth/token.

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) SetPipelineCancelResponse

func (f *CircleCI) SetPipelineCancelResponse(pipelineID string, status int)

SetPipelineCancelResponse sets the HTTP status code returned for POST /api/v2/pipeline/<id>/cancel. Use http.StatusAccepted (202) for success.

func (*CircleCI) SetRerunResponse

func (f *CircleCI) SetRerunResponse(workflowID string, status int)

SetRerunResponse sets the HTTP status code returned for POST /api/v2/workflow/<id>/rerun. Use http.StatusAccepted (202) for success.

func (*CircleCI) SetTriggerResponse

func (f *CircleCI) SetTriggerResponse(slug string, resp any)

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) URL

func (f *CircleCI) URL() string

URL returns the base URL of the fake server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL