testutil

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: GPL-3.0, LGPL-3.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testutil provides shared test helpers used across sind packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArgValue

func ArgValue(args []string, flag string) (string, bool)

ArgValue returns the value following the first occurrence of flag in args.

func ArgValues

func ArgValues(args []string, flag string) []string

ArgValues returns all values following each occurrence of flag in args.

func ExitCode1

func ExitCode1(t *testing.T) *exec.ExitError

ExitCode1 returns an *exec.ExitError with exit code 1. This is used to mock Docker inspect commands that return exit code 1 for missing resources.

func Image added in v0.13.0

func Image() string

Image returns the sind-node image the tests run: SIND_TEST_IMAGE, or ghcr.io/gsi-hpc/sind-node:latest when it is unset.

func NDJSON

func NDJSON[T any](entries ...T) string

NDJSON builds newline-delimited JSON from the given entries.

func NewClient

func NewClient(t *testing.T) (*docker.Client, *mock.Recorder)

NewClient returns a docker.Client backed by a MockExecutor.

func NoSuchContainer added in v0.10.0

func NoSuchContainer(name string) string

NoSuchContainer returns what docker writes to stderr, with exit code 1, for a container that does not exist. Paired with ExitCode1 in a mock result, it gives the error the real executor returns, which docker.IsNotFound recognises.

func NoSuchNetwork added in v0.10.0

func NoSuchNetwork(name string) string

NoSuchNetwork is NoSuchContainer for a network.

func NoSuchVolume added in v0.10.0

func NoSuchVolume(name string) string

NoSuchVolume is NoSuchContainer for a volume.

func Realm

func Realm(string) string

Realm returns the default realm "sind" in unit mode. In integration mode it returns a unique random realm with the given prefix.

func TarArchive

func TarArchive(name, content string) string

TarArchive builds a tar archive containing a single file with the given name and content.

func TarModes added in v0.13.0

func TarModes(t *testing.T, archive string) map[string]int64

TarModes returns the mode of each file in a tar archive, as docker cp receives it on stdin.

func WithoutCalls added in v0.13.0

func WithoutCalls(events []progress.Event) string

WithoutCalls draws the spans of events as progresstest.Capture.Tree does, leaving out the calls and what is under them: the docker commands, which the tests of the docker package cover, and of which a wait that polls runs as many as its rounds take.

Types

type PsEntry

type PsEntry struct {
	ID       string `json:"ID"`
	Names    string `json:"Names"`
	State    string `json:"State"`
	Status   string `json:"Status,omitempty"`
	Image    string `json:"Image"`
	Labels   string `json:"Labels,omitempty"`
	Networks string `json:"Networks,omitempty"`
}

PsEntry mirrors the docker ps --format json output structure.

Jump to

Keyboard shortcuts

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