Help us shape the future of Go! Take the 2026 Go Developer Survey

fakes

package
v0.7.122 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSSHKeypair added in v0.7.9

func GenerateSSHKeypair(t *testing.T) (keyFile string, pubKey ssh.PublicKey)

GenerateSSHKeypair generates an ed25519 keypair, writes the private and public key files to a temp directory, and returns the private key file path and the corresponding ssh.PublicKey.

Types

type Collaboration

type Collaboration struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	VCSType string `json:"vcs-type"`
	Slug    string `json:"slug"`
}

type CommandResponse added in v0.7.97

type CommandResponse struct {
	ID        string  `json:"id"`
	CreatedAt string  `json:"created_at"`
	EndedAt   *string `json:"ended_at,omitempty"`
	ExitCode  *int    `json:"exit_code,omitempty"`
	Outcome   *string `json:"outcome,omitempty"`
	Phase     string  `json:"phase"`
	SidecarID string  `json:"sidecar_id"`
}

type ExecResponse

type ExecResponse struct {
	CommandID string `json:"command_id"`
	PID       int    `json:"pid"`
	Stdout    string `json:"stdout"`
	Stderr    string `json:"stderr"`
	ExitCode  int    `json:"exit_code"`
}

type FakeAnthropic

type FakeAnthropic struct {
	http.Handler
	Recorder *recorder.RequestRecorder
	// contains filtered or unexported fields
}

FakeAnthropic serves canned responses for the Anthropic Messages API.

func NewFakeAnthropic

func NewFakeAnthropic(responses ...string) *FakeAnthropic

func (*FakeAnthropic) SetTokenLimitErrors

func (f *FakeAnthropic) SetTokenLimitErrors(n int)

SetTokenLimitErrors configures the fake to return n consecutive "prompt is too long" errors before returning normal responses.

type FakeCircleCI

type FakeCircleCI struct {
	http.Handler
	Recorder *recorder.RequestRecorder

	Collaborations  []Collaboration
	Projects        []Project
	Sidecars        []Sidecar
	Snapshots       []Snapshot
	RunResponse     *RunResponse
	AddKeyURL       string
	ExecResponse    *ExecResponse
	CommandResponse *CommandResponse
	RunStatusCode   int // override status code for trigger run endpoint

	// Per-endpoint status code overrides for testing error responses.
	CollaborationsStatusCode int // override for GET /me/collaborations
	ListStatusCode           int // override for GET /sidecar/instances
	CreateStatusCode         int // override for POST /sidecar/instances
	DeleteStatusCode         int // override for DELETE /sidecar/instances/:id
	ExecStatusCode           int // override for POST /sidecar/instances/:id/exec
	AddKeyStatusCode         int // override for POST /sidecar/instances/:id/ssh/add-key
	CreateSnapshotStatusCode int // override for POST /sidecar/snapshots
	GetSnapshotStatusCode    int // override for GET /sidecar/snapshots/:id
	ListSnapshotsStatusCode  int // override for GET /sidecar/snapshots
	GetCommandStatusCode     int // override for GET /sidecar/commands/:id
	CreateOrgStatusCode      int // override for POST /api/v2/organization
	// contains filtered or unexported fields
}

FakeCircleCI serves canned responses for the CircleCI API.

func NewFakeCircleCI

func NewFakeCircleCI() *FakeCircleCI

type FakeGitHub

type FakeGitHub struct {
	http.Handler
	Recorder *recorder.RequestRecorder
	// contains filtered or unexported fields
}

FakeGitHub serves canned responses for GitHub's GraphQL API.

func NewFakeGitHub

func NewFakeGitHub() *FakeGitHub

func (*FakeGitHub) SetOrgRepos

func (f *FakeGitHub) SetOrgRepos(resp string)

func (*FakeGitHub) SetOrgValidation

func (f *FakeGitHub) SetOrgValidation(resp string)

func (*FakeGitHub) SetRateLimit

func (f *FakeGitHub) SetRateLimit(resp string)

func (*FakeGitHub) SetRepoError

func (f *FakeGitHub) SetRepoError(repo string, resp string)

func (*FakeGitHub) SetReviewActivity

func (f *FakeGitHub) SetReviewActivity(repo string, resp string)

type Project

type Project struct {
	VCSType  string `json:"vcs_type"`
	Username string `json:"username"`
	Reponame string `json:"reponame"`
}

type RunResponse

type RunResponse struct {
	RunID      string `json:"runId,omitempty"`
	PipelineID string `json:"pipelineId,omitempty"`
}

type SSHServer added in v0.7.9

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

SSHServer is a WebSocket+SSH server for testing SSH-based sidecar interactions. It accepts a single authorized public key and records exec requests.

func NewSSHServer added in v0.7.9

func NewSSHServer(t *testing.T, authorizedKey ssh.PublicKey) *SSHServer

NewSSHServer starts a WebSocket+SSH server that accepts connections authenticated with authorizedKey. The server is shut down automatically when the test ends.

func (*SSHServer) Addr added in v0.7.9

func (s *SSHServer) Addr() string

Addr returns the "host:port" address the server is listening on. sidecar.OpenSession stores this as Session.URL; toWebSocketURL converts it to ws://host:port/ssh/tunnel before dialling.

func (*SSHServer) Commands added in v0.7.9

func (s *SSHServer) Commands() []string

Commands returns a copy of all exec command strings received so far.

func (*SSHServer) EnvVars added in v0.7.57

func (s *SSHServer) EnvVars() map[string]string

EnvVars returns a copy of all environment variables received via "env" requests.

func (*SSHServer) Reset added in v0.7.122

func (s *SSHServer) Reset()

Reset clears the recorded commands so a test can assert on a fresh sync.

func (*SSHServer) SetResult added in v0.7.9

func (s *SSHServer) SetResult(stdout string, exitCode int)

SetResult configures the stdout output and exit code returned for exec requests.

type Sidecar added in v0.7.31

type Sidecar struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	OrgID    string `json:"org_id"`
	Provider string `json:"provider,omitempty"`
	Image    string `json:"image,omitempty"`
}

type Snapshot added in v0.7.27

type Snapshot struct {
	ID    string `json:"id"`
	OrgID string `json:"org_id"`
	Name  string `json:"name"`
	Tag   string `json:"tag,omitempty"`
}

Jump to

Keyboard shortcuts

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