support

package
v1.10.5 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 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 gtb binary, building it on first call. The binary is placed in a temp directory and reused for all subsequent calls.

func CleanupBinary

func CleanupBinary()

CleanupBinary removes the temporary binary directory.

func FreePort

func FreePort() (int, error)

FreePort obtains a free TCP port.

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