testutil

package
v0.5.2 Latest Latest
Warning

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

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

Documentation

Overview

Package testutil holds helpers shared by devbay's Docker integration tests.

It exists because two things are true on a clean Linux machine and false on the developer machine the tests were written on, and both of them look like flakiness rather than what they are:

  • An image the test never pulled is not there. Locally every image is in the cache from a previous run, so a test that creates a container from `alpine:3.20` without pulling it works forever and then fails the first time it meets a fresh runner.

  • A container writes as root, and on Linux that is the host's ownership. Anything a container leaves in a bind-mounted directory -- including the empty mountpoint Docker creates when a volume is mounted at a path inside a bind mount -- is root-owned, and `t.TempDir()`'s own cleanup cannot remove it. macOS maps ownership and never shows this.

Both are properties of the environment, so they belong in one place rather than being rediscovered per package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PullImage

func PullImage(ctx context.Context, t *testing.T, cli *client.Client, ref string)

PullImage makes sure an image is present, pulling it if not.

Call it before creating a container directly. Code paths that go through the engine or the proxy pull for themselves; a test that reaches for the Docker API on its own has to do the same.

func ReclaimOnCleanup

func ReclaimOnCleanup(t *testing.T, cli *client.Client, dir string)

ReclaimOnCleanup arranges for dir to be owned by this process again once the test finishes.

Call it immediately after creating the directory. Cleanups run last registered first, so registering this after `t.TempDir()` means ownership is restored before that directory's own removal is attempted -- which is the whole point, since otherwise the removal is what fails.

A failure here is logged rather than fatal: the test's actual subject has already been decided by this point, and turning "the runner could not tidy up" into a red test would hide the result that matters.

Types

This section is empty.

Jump to

Keyboard shortcuts

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