fake

package
v0.0.0-...-2766734 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package fake is the test double for dockerruntime.Runtime: a typed recorder. Every call lands in Calls with its arguments, so tests assert on structs (image, env, labels, stop timeout) instead of substring-matching shell strings — the pattern replacing the sshexec-era command-string assertions.

Behavior is scripted per method through the *Fn fields. A nil Fn on a method that only returns an error succeeds silently (the common case for mutations); a nil Fn on a method that returns a value panics, so a test exercising a read path must say what the daemon would answer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Method string
	Args   []any
}

Call is one recorded invocation: the method name and its arguments in declaration order (ctx excluded).

type Runtime

type Runtime struct {
	ContainerCreateFn      func(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error)
	ContainerStartFn       func(ctx context.Context, name string, options container.StartOptions) error
	ContainerStopFn        func(ctx context.Context, name string, options container.StopOptions) error
	ContainerRestartFn     func(ctx context.Context, name string, options container.StopOptions) error
	ContainerRenameFn      func(ctx context.Context, name, newName string) error
	ContainerRemoveFn      func(ctx context.Context, name string, options container.RemoveOptions) error
	ContainerInspectFn     func(ctx context.Context, name string) (container.InspectResponse, error)
	ContainerWaitFn        func(ctx context.Context, name string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)
	ContainerListFn        func(ctx context.Context, options container.ListOptions) ([]container.Summary, error)
	ContainerLogsFn        func(ctx context.Context, name string, options container.LogsOptions) (io.ReadCloser, error)
	ContainerStatsFn       func(ctx context.Context, name string, stream bool) (container.StatsResponseReader, error)
	ContainersPruneFn      func(ctx context.Context, pruneFilters filters.Args) (container.PruneReport, error)
	ContainerExecCreateFn  func(ctx context.Context, name string, options container.ExecOptions) (container.ExecCreateResponse, error)
	ContainerExecStartFn   func(ctx context.Context, execID string, options container.ExecStartOptions) error
	ContainerExecAttachFn  func(ctx context.Context, execID string, options container.ExecAttachOptions) (types.HijackedResponse, error)
	ContainerExecInspectFn func(ctx context.Context, execID string) (container.ExecInspect, error)
	ContainerExecResizeFn  func(ctx context.Context, execID string, options container.ResizeOptions) error
	ImagePullFn            func(ctx context.Context, ref string, options image.PullOptions) (io.ReadCloser, error)
	ImagePushFn            func(ctx context.Context, ref string, options image.PushOptions) (io.ReadCloser, error)
	ImageTagFn             func(ctx context.Context, img, ref string) error
	ImageInspectFn         func(ctx context.Context, img string, options ...client.ImageInspectOption) (image.InspectResponse, error)
	ImageListFn            func(ctx context.Context, options image.ListOptions) ([]image.Summary, error)
	ImageRemoveFn          func(ctx context.Context, img string, options image.RemoveOptions) ([]image.DeleteResponse, error)
	ImagesPruneFn          func(ctx context.Context, pruneFilter filters.Args) (image.PruneReport, error)
	VolumeCreateFn         func(ctx context.Context, options volume.CreateOptions) (volume.Volume, error)
	VolumeInspectFn        func(ctx context.Context, volumeID string) (volume.Volume, error)
	VolumeListFn           func(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error)
	VolumeRemoveFn         func(ctx context.Context, volumeID string, force bool) error
	VolumesPruneFn         func(ctx context.Context, pruneFilter filters.Args) (volume.PruneReport, error)
	NetworkCreateFn        func(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error)
	NetworkConnectFn       func(ctx context.Context, networkID, name string, config *network.EndpointSettings) error
	NetworkDisconnectFn    func(ctx context.Context, networkID, name string, force bool) error
	NetworkInspectFn       func(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, error)
	NetworkListFn          func(ctx context.Context, options network.ListOptions) ([]network.Summary, error)
	NetworkRemoveFn        func(ctx context.Context, networkID string) error
	NetworksPruneFn        func(ctx context.Context, pruneFilter filters.Args) (network.PruneReport, error)
	EventsFn               func(ctx context.Context, options events.ListOptions) (<-chan events.Message, <-chan error)
	InfoFn                 func(ctx context.Context) (system.Info, error)
	ServerVersionFn        func(ctx context.Context) (types.Version, error)
	DiskUsageFn            func(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error)
	RegistryLoginFn        func(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error)
	PingFn                 func(ctx context.Context) (types.Ping, error)
	CloseFn                func() error
	// contains filtered or unexported fields
}

Runtime records calls and plays scripted responses.

func (*Runtime) CallNames

func (f *Runtime) CallNames() []string

CallNames returns just the method names, in order — the quick shape assertion ("Remove then Create then Start").

func (*Runtime) Calls

func (f *Runtime) Calls() []Call

Calls returns the recorded invocations in order.

func (*Runtime) Close

func (f *Runtime) Close() error

func (*Runtime) ContainerCreate

func (f *Runtime) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error)

func (*Runtime) ContainerExecAttach

func (f *Runtime) ContainerExecAttach(ctx context.Context, execID string, options container.ExecAttachOptions) (types.HijackedResponse, error)

func (*Runtime) ContainerExecCreate

func (f *Runtime) ContainerExecCreate(ctx context.Context, name string, options container.ExecOptions) (container.ExecCreateResponse, error)

func (*Runtime) ContainerExecInspect

func (f *Runtime) ContainerExecInspect(ctx context.Context, execID string) (container.ExecInspect, error)

func (*Runtime) ContainerExecResize

func (f *Runtime) ContainerExecResize(ctx context.Context, execID string, options container.ResizeOptions) error

func (*Runtime) ContainerExecStart

func (f *Runtime) ContainerExecStart(ctx context.Context, execID string, options container.ExecStartOptions) error

func (*Runtime) ContainerInspect

func (f *Runtime) ContainerInspect(ctx context.Context, name string) (container.InspectResponse, error)

func (*Runtime) ContainerList

func (f *Runtime) ContainerList(ctx context.Context, options container.ListOptions) ([]container.Summary, error)

func (*Runtime) ContainerLogs

func (f *Runtime) ContainerLogs(ctx context.Context, name string, options container.LogsOptions) (io.ReadCloser, error)

func (*Runtime) ContainerRemove

func (f *Runtime) ContainerRemove(ctx context.Context, name string, options container.RemoveOptions) error

func (*Runtime) ContainerRename

func (f *Runtime) ContainerRename(ctx context.Context, name, newName string) error

func (*Runtime) ContainerRestart

func (f *Runtime) ContainerRestart(ctx context.Context, name string, options container.StopOptions) error

func (*Runtime) ContainerStart

func (f *Runtime) ContainerStart(ctx context.Context, name string, options container.StartOptions) error

func (*Runtime) ContainerStats

func (f *Runtime) ContainerStats(ctx context.Context, name string, stream bool) (container.StatsResponseReader, error)

func (*Runtime) ContainerStop

func (f *Runtime) ContainerStop(ctx context.Context, name string, options container.StopOptions) error

func (*Runtime) ContainerWait

func (f *Runtime) ContainerWait(ctx context.Context, name string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)

func (*Runtime) ContainersPrune

func (f *Runtime) ContainersPrune(ctx context.Context, pruneFilters filters.Args) (container.PruneReport, error)

func (*Runtime) DiskUsage

func (f *Runtime) DiskUsage(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error)

func (*Runtime) Events

func (f *Runtime) Events(ctx context.Context, options events.ListOptions) (<-chan events.Message, <-chan error)

func (*Runtime) ImageInspect

func (f *Runtime) ImageInspect(ctx context.Context, img string, options ...client.ImageInspectOption) (image.InspectResponse, error)

func (*Runtime) ImageList

func (f *Runtime) ImageList(ctx context.Context, options image.ListOptions) ([]image.Summary, error)

func (*Runtime) ImagePull

func (f *Runtime) ImagePull(ctx context.Context, ref string, options image.PullOptions) (io.ReadCloser, error)

func (*Runtime) ImagePush

func (f *Runtime) ImagePush(ctx context.Context, ref string, options image.PushOptions) (io.ReadCloser, error)

func (*Runtime) ImageRemove

func (f *Runtime) ImageRemove(ctx context.Context, img string, options image.RemoveOptions) ([]image.DeleteResponse, error)

func (*Runtime) ImageTag

func (f *Runtime) ImageTag(ctx context.Context, img, ref string) error

func (*Runtime) ImagesPrune

func (f *Runtime) ImagesPrune(ctx context.Context, pruneFilter filters.Args) (image.PruneReport, error)

func (*Runtime) Info

func (f *Runtime) Info(ctx context.Context) (system.Info, error)

func (*Runtime) NetworkConnect

func (f *Runtime) NetworkConnect(ctx context.Context, networkID, name string, config *network.EndpointSettings) error

func (*Runtime) NetworkCreate

func (f *Runtime) NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error)

func (*Runtime) NetworkDisconnect

func (f *Runtime) NetworkDisconnect(ctx context.Context, networkID, name string, force bool) error

func (*Runtime) NetworkInspect

func (f *Runtime) NetworkInspect(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, error)

func (*Runtime) NetworkList

func (f *Runtime) NetworkList(ctx context.Context, options network.ListOptions) ([]network.Summary, error)

func (*Runtime) NetworkRemove

func (f *Runtime) NetworkRemove(ctx context.Context, networkID string) error

func (*Runtime) NetworksPrune

func (f *Runtime) NetworksPrune(ctx context.Context, pruneFilter filters.Args) (network.PruneReport, error)

func (*Runtime) Ping

func (f *Runtime) Ping(ctx context.Context) (types.Ping, error)

func (*Runtime) RegistryLogin

func (f *Runtime) RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error)

func (*Runtime) ServerVersion

func (f *Runtime) ServerVersion(ctx context.Context) (types.Version, error)

func (*Runtime) VolumeCreate

func (f *Runtime) VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error)

func (*Runtime) VolumeInspect

func (f *Runtime) VolumeInspect(ctx context.Context, volumeID string) (volume.Volume, error)

func (*Runtime) VolumeList

func (f *Runtime) VolumeList(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error)

func (*Runtime) VolumeRemove

func (f *Runtime) VolumeRemove(ctx context.Context, volumeID string, force bool) error

func (*Runtime) VolumesPrune

func (f *Runtime) VolumesPrune(ctx context.Context, pruneFilter filters.Args) (volume.PruneReport, error)

Jump to

Keyboard shortcuts

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