support

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 13 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 FreePort

func FreePort() (int, error)

FreePort obtains a free TCP port.

func GeneratorBinaryPath added in v0.17.0

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
	Counters   map[string]*StateCounters
	LogBuf     *SyncBuffer
	Logger     logger.Logger
	HTTPPort   int
	GRPCPort   int

	// Health check tracking
	CheckCounts map[string]*atomic.Int64

	// Channels for coordination
	RequestStarted  chan struct{}
	RequestFinished chan struct{}
	ClientResult    chan error
	StartupDelay    chan struct{}
}

ControllerWorld holds per-scenario state for controls BDD tests.

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) RegisterService

func (w *ControllerWorld) RegisterService(name string, extraOpts ...controls.ServiceOption) *StateCounters

RegisterService registers a service with atomic counters for tracking.

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 StateCounters

type StateCounters struct {
	Started  atomic.Int64
	Stopped  atomic.Int64
	Statused atomic.Int64
}

StateCounters tracks service lifecycle invocations atomically.

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