testharness

package
v0.1.210 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Harness

type Harness struct {
	Metadata map[string]string
	Outputs  []PortMsg
	// contains filtered or unexported fields
}

Harness wraps a component for testing. Captures all port outputs and manages metadata persistence.

func New

func New(c module.Component) *Harness

New creates a harness for the given component instance.

func (*Harness) Handle

func (h *Harness) Handle(ctx context.Context, port string, msg any) any

Handle sends a message to the component on the given port.

func (*Harness) HandleAsLeader

func (h *Harness) HandleAsLeader(ctx context.Context, port string, msg any) any

HandleAsLeader sends a message with IsLeader=true in context.

func (*Harness) Handler

func (h *Harness) Handler(ctx context.Context, port string, data any) any

Handler implements module.Handler, capturing outputs and metadata writes.

func (*Harness) LeaderHandler

func (h *Harness) LeaderHandler(ctx context.Context, port string, data any) any

LeaderHandler returns a handler with IsLeader=true in context.

func (*Harness) NewPod

func (h *Harness) NewPod() *Harness

NewPod simulates a pod restart: fresh component instance, same metadata.

func (*Harness) PortOutputs

func (h *Harness) PortOutputs(port string) []any

PortOutputs returns all data sent to the given port.

func (*Harness) Ports

func (h *Harness) Ports() []module.Port

Ports returns the component's current port definitions.

func (*Harness) Reconcile

func (h *Harness) Reconcile(ctx context.Context) any

Reconcile simulates a reconcile event with current metadata.

func (*Harness) ReconcileAsLeader

func (h *Harness) ReconcileAsLeader(ctx context.Context) any

ReconcileAsLeader simulates a reconcile with IsLeader=true.

func (*Harness) Reset

func (h *Harness) Reset()

Reset clears captured outputs (but keeps metadata).

type PortMsg

type PortMsg struct {
	Port string
	Data any
}

PortMsg captures a single output sent by a component via handler()

Jump to

Keyboard shortcuts

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