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

dockertest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package dockertest fakes the Docker Engine API, so tests of services that run containers pass without an engine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine struct {
	Port int  // the host port inspect reports; point it at a listener of the test
	Down bool // answer like an engine that is not running
	// contains filtered or unexported fields
}

Engine records what services ask of it, docker CLI style: "create --name n -p 127.0.0.1:h:p -e K=V image args…", "start n", "stop n", "restart n", "exec n cmd…", "rm -f -v n", and for volumes "volume create v", "volume rm v" and "bind n v:/path" (a container's named volume). Every published port is Port on inspect.

func Start

func Start(t testing.TB, port int, down bool) *Engine

Start serves a fake engine until the test ends and points DOCKER_HOST at it.

func (*Engine) Called

func (e *Engine) Called(prefix string) []string

Called lists the recorded calls that start with prefix.

func (*Engine) DropVolume added in v0.2.0

func (e *Engine) DropVolume(name string)

DropVolume forgets a volume, as if someone removed it behind pogi's back.

func (*Engine) HasVolume added in v0.2.0

func (e *Engine) HasVolume(name string) bool

HasVolume reports whether a named volume exists.

func (*Engine) ServeHTTP

func (e *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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