Documentation
¶
Index ¶
- type Harness
- func (h *Harness) Handle(ctx context.Context, port string, msg any) module.Result
- func (h *Harness) HandleAsLeader(ctx context.Context, port string, msg any) module.Result
- func (h *Harness) Handler(ctx context.Context, port string, data any) module.Result
- func (h *Harness) LeaderHandler(ctx context.Context, port string, data any) module.Result
- func (h *Harness) NewPod() *Harness
- func (h *Harness) PortOutputs(port string) []any
- func (h *Harness) Ports() []module.Port
- func (h *Harness) Reconcile(ctx context.Context) module.Result
- func (h *Harness) ReconcileAsLeader(ctx context.Context) module.Result
- func (h *Harness) Reset()
- type PortMsg
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 ¶
New creates a harness for the given component instance. The harness mirrors the scheduler's capability injection so components written against the new lifecycle interfaces (OnSettings, OnReconcile, OnControl, OnEmitter, OnState, etc.) work in tests the same way they do in the runner.
func (*Harness) Handle ¶
Handle sends a message to the component on the given port. For system ports, dispatches through the matching capability interface when the component implements one (mirroring scheduler.Update's Phase 1). For other ports, falls through to Component.Handle.
func (*Harness) HandleAsLeader ¶
HandleAsLeader sends a message with IsLeader=true in context.
func (*Harness) Handler ¶
Handler implements module.Handler, capturing outputs and metadata writes. Reconcile-port updaters are applied to both h.Metadata (legacy hand-rolled access) and the fake K8s client (so State.Get sees them).
func (*Harness) LeaderHandler ¶
LeaderHandler returns a handler with IsLeader=true in context.
func (*Harness) NewPod ¶
NewPod simulates a pod restart: fresh component instance, same metadata. Reinjects all SDK capabilities on the new instance so it behaves like a freshly scheduled runner.
func (*Harness) PortOutputs ¶
PortOutputs returns all data sent to the given port.
func (*Harness) ReconcileAsLeader ¶
ReconcileAsLeader simulates a reconcile with IsLeader=true.