Help us shape the future of Go! Take the 2026 Go Developer Survey

support

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package support provides shared test harness helpers for E2E/BDD tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BinaryPath

func BinaryPath() (string, error)

BinaryPath returns the path to the compiled e2e test binary (./cmd/e2e), building it on first call. The binary is placed in a temp directory and reused for all subsequent calls.

The e2e binary enables every feature flag (including InitCmd) so that framework scenarios — init, doctor, config, chat, controls — can be exercised. CLI scenarios that drive it must therefore provide a config file, because an InitCmd-enabled tool requires one at bootstrap.

func CleanupBinary

func CleanupBinary()

CleanupBinary removes the temporary binary directories.

func FrameworkRoot added in v0.43.0

func FrameworkRoot() string

projectRoot walks up from the current working directory to find go.mod. FrameworkRoot is the go-tool-base working tree: the directory holding go.work, above the cli module. Generator scenarios hand it to gtb as GTB_FRAMEWORK_REPLACE so a scaffold that references framework API newer than the latest release still tidies; the workspace keeps the cli and the framework in step, and this keeps the scaffolds in step with both.

func FreePort

func FreePort() (int, error)

FreePort obtains a free TCP port.

func GeneratorBinaryPath

func GeneratorBinaryPath() (string, error)

GeneratorBinaryPath returns the path to the compiled real gtb binary (./cmd/gtb), building it on first call.

Generator scenarios must use this binary, not the e2e binary: the real gtb tool disables InitCmd (internal/cmd/root), so its bootstrap treats a missing config as allow-empty and the generate/regenerate/remove commands run without an external config file — exactly as they do in production. Driving them through the InitCmd-enabled e2e binary would instead demand a config file and misrepresent how the generator actually runs.

Types

type ControllerWorld

type ControllerWorld struct {
	Controller *controls.Controller
	Ctx        context.Context
	Cancel     context.CancelFunc
	LogBuf     *SyncBuffer
	Logger     logger.Logger
	HTTPPort   int
	GRPCPort   int

	// RateLimitStatuses collects the HTTP status codes from a burst of requests
	// sent by the rate-limiting scenarios.
	RateLimitStatuses []int
}

ControllerWorld holds per-scenario state for the transport-adapter scenarios.

func NewControllerWorld

func NewControllerWorld() *ControllerWorld

NewControllerWorld creates a fresh scenario world.

func (*ControllerWorld) Cleanup

func (w *ControllerWorld) Cleanup()

Cleanup stops the controller if still running.

func (*ControllerWorld) EnsureController

func (w *ControllerWorld) EnsureController(opts ...controls.ControllerOpt)

EnsureController creates the controller if it doesn't exist yet.

func (*ControllerWorld) WaitForState

func (w *ControllerWorld) WaitForState(state controls.State, timeout time.Duration) error

WaitForState polls until the controller reaches the desired state or timeout.

type SyncBuffer

type SyncBuffer struct {
	// contains filtered or unexported fields
}

SyncBuffer is a thread-safe bytes.Buffer for capturing log output.

func (*SyncBuffer) String

func (b *SyncBuffer) String() string

func (*SyncBuffer) Write

func (b *SyncBuffer) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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