dockertest

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package dockertest provides a minimal fake Docker Engine API for unit tests in other packages. It enforces the same allow-list as cmd/socket-proxy (403 otherwise) and returns type-appropriate bodies so the SDK wrapper's methods succeed without a real daemon.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Method string
	Path   string
	Body   []byte
}

Call is one request the fake received.

type Fake

type Fake struct {
	Server *httptest.Server

	// ImageUser is returned from image inspect ("" means the image declares no USER).
	ImageUser string
	// Denied records requests rejected by the allow-list.
	Denied []Call
	// Containers lists summaries returned by GET /containers/json.
	Containers []map[string]any
	// contains filtered or unexported fields
}

Fake is a fake Docker daemon.

func New

func New(t *testing.T) *Fake

New starts a fake daemon; it is closed automatically when the test ends.

func (*Fake) Calls

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

Calls returns a copy of all accepted calls.

func (*Fake) CreateBodies

func (f *Fake) CreateBodies() []map[string]any

CreateBodies returns the decoded JSON bodies of every POST /containers/create.

func (*Fake) Host

func (f *Fake) Host() string

Host returns the tcp:// host string for docker.New.

Jump to

Keyboard shortcuts

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