testsupport

package
v1.0.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package testsupport holds the helpers the repository's tests share. Nothing outside tests imports it; nothing in it is product code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildBrigada

func BuildBrigada(t testing.TB) string

BuildBrigada builds the brigada binary once per test binary and returns its path, failing the test when the build does. The lifecycle and CLI tests run it as a real process: engines detached by clients, runners polling, the whole §13 story.

func DisableGitAutoMaintenance

func DisableGitAutoMaintenance()

DisableGitAutoMaintenance turns off git's automatic garbage collection and background maintenance for every git command this process spawns, including the ones the code under test starts. Git writes into .git in the background while those commands run, and that races a test's TempDir cleanup: RemoveAll can fail with "unlinkat .../.git: directory not empty" when git repacks the repository between the listing and the unlink. The two settings go through GIT_CONFIG_* so they reach every repository the tests create, including plain `git init` ones that no template config reaches.

This is a process-level setting meant for TestMain, not t.Setenv: tests spawn git directly and through helpers, and each of those inherits the process environment.

func NewGitRemote

func NewGitRemote(t testing.TB) string

NewGitRemote creates a local bare git remote holding one commit on main, the stand-in for a task's repo (§5.1): file-path URLs, no network, no credentials. The template is built by the process's first call; every call then writes its own copy — files and directories, empty ones included — under the test's temp dir, removed when the test ends.

func OpenStore

func OpenStore(t testing.TB) *store.Store

OpenStore opens a private, fully migrated store for one test: a copy of the process's template in the test's own temp dir, removed when the test ends. Unlike store.Open's ":memory:", the store is a file, so the pool may hand the test several connections.

func ShortSocketPath

func ShortSocketPath(t testing.TB) string

ShortSocketPath returns a fresh, short path for one test's Unix socket, with its directory removed when the test ends. A kernel's sockaddr_un takes at most 104 bytes of path (macOS; 108 on Linux), and the obvious spot — t.TempDir(), whose name carries the test's — runs past that where temporary directories are long, so the bind fails with a bare "invalid argument". The socket gets its own short directory instead: under os.TempDir() when that leaves room, under /tmp otherwise. The result is asserted under 100 bytes — inside every kernel's cap with room to spare.

func ShortStateDir

func ShortStateDir(t testing.TB) string

ShortStateDir returns a fresh, short directory for one test's engine state, removed when the test ends. The socket inside it — <dir>/brigada.sock — must stay under the kernel's sun_path cap, which t.TempDir()'s test-named paths cannot promise; the directory is checked against the same 100-byte bound as ShortSocketPath.

Types

This section is empty.

Jump to

Keyboard shortcuts

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