phasetest

package
v11.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package phasetest provides fake phase CLI binaries for testing phasekit integrations without network access.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeBinary

type FakeBinary struct {
	// Path is the absolute path to the fake phase binary.
	Path string
	// contains filtered or unexported fields
}

FakeBinary describes a fake phase binary installed on PATH for a test.

func WithFakeBinary

func WithFakeBinary(t testing.TB, opts FakeOptions) *FakeBinary

WithFakeBinary writes a fake phase binary, prepends it to PATH, and returns an object that can read the recorded argv and environment after invocation.

func (*FakeBinary) Args

func (f *FakeBinary) Args(t testing.TB) []string

Args returns the argv values recorded by the fake binary.

func (*FakeBinary) Env

func (f *FakeBinary) Env(t testing.TB) map[string]string

Env returns the requested environment variables recorded by the fake binary.

type FakeOptions

type FakeOptions struct {
	// Secrets is marshaled to JSON and written to stdout when RawStdout is empty.
	Secrets map[string]string

	// RawStdout is written to stdout verbatim when non-empty.
	RawStdout string

	// Stderr is written to stderr verbatim.
	Stderr string

	// ExitCode is the process exit code. Defaults to 0.
	ExitCode int

	// Delay sleeps before emitting output. Useful for timeout tests.
	Delay time.Duration

	// RecordEnv names environment variables the fake binary should record.
	RecordEnv []string
}

FakeOptions controls the behavior of WithFakeBinary.

Jump to

Keyboard shortcuts

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