testutil

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 9 Imported by: ? 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

Index

Constants

View Source
const (
	// DefaultTimeout caps each `vers` invocation in integration tests.
	// Must exceed the CLI's longest internal context budget (APILong = 120s)
	// so the CLI gets room to either succeed or return a clean
	// context-deadline error before the test wrapper kills the process.
	DefaultTimeout = 180 * time.Second
)

Variables

View Source
var (
	BinPath string
)

Functions

func EnsureBuilt

func EnsureBuilt(t TLike)

EnsureBuilt builds the CLI binary if it doesn't exist.

func ParseVMID

func ParseVMID(output string) (string, error)

ParseVMID extracts the VM ID from `vers run` output. The output format is: "VM '<vmID>' started successfully."

func RegisterVMCleanup

func RegisterVMCleanup(t TLike, identifier string, _ ...bool)

RegisterVMCleanup ensures a VM is deleted at test end.

func RunVers

func RunVers(t TLike, timeout time.Duration, args ...string) (string, error)

RunVers executes the CLI with a timeout and returns combined stdout/stderr and error.

func RunVersInDir added in v0.6.0

func RunVersInDir(t TLike, dir string, timeout time.Duration, args ...string) (string, error)

RunVersInDir executes the CLI in a specific working directory.

func TestEnv

func TestEnv(t TLike)

TestEnv ensures required env vars are present; loads root .env if found.

func UniqueAlias

func UniqueAlias(prefix string) string

UniqueAlias returns a unique alias string scoped to a test run.

Types

type TLike

type TLike interface {
	Cleanup(func())
	Fatalf(string, ...any)
	Skipf(string, ...any)
}

TLike is the subset of *testing.T methods we use; helps reuse in helpers.

Jump to

Keyboard shortcuts

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