componenttest

package
v0.39.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package componenttest provides utilities for testing Flow components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestContext

func TestContext(t testing.TB) context.Context

TestContext returns a context which cancels itself when t finishes.

Types

type Controller

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

A Controller is a testing controller which controls a single component.

func NewControllerFromID

func NewControllerFromID(l log.Logger, componentName string) (*Controller, error)

NewControllerFromID returns a new testing Controller for the component with the provided name.

func NewControllerFromReg added in v0.29.0

func NewControllerFromReg(l log.Logger, reg component.Registration) *Controller

NewControllerFromReg registers a new testing Controller for a component with the given registration. This can be used for testing fake components which aren't really registered.

func (*Controller) Exports

func (c *Controller) Exports() component.Exports

Exports gets the most recent exports for a component.

func (*Controller) Run

func (c *Controller) Run(ctx context.Context, args component.Arguments) error

Run starts the controller, building and running the component. Run blocks until ctx is canceled, the component exits, or if there was an error.

Run may only be called once per Controller.

func (*Controller) Update

func (c *Controller) Update(args component.Arguments) error

Update updates the running component. Should only be called after Run.

func (*Controller) WaitExports

func (c *Controller) WaitExports(timeout time.Duration) error

WaitExports blocks until new Exports are available up to the provided timeout.

func (*Controller) WaitRunning

func (c *Controller) WaitRunning(timeout time.Duration) error

WaitRunning blocks until the Controller is running up to the provided timeout.

type TestFailArguments added in v0.38.0

type TestFailArguments struct {
	Content string `river:"content,attr"`
	Fail    bool   `river:"fail,attr,optional"`
}

type TestFailModule added in v0.38.0

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

func (*TestFailModule) Run added in v0.38.0

func (t *TestFailModule) Run(ctx context.Context) error

func (*TestFailModule) Update added in v0.38.0

func (t *TestFailModule) Update(_ component.Arguments) error

func (*TestFailModule) UpdateContent added in v0.38.0

func (t *TestFailModule) UpdateContent(content string) error

Jump to

Keyboard shortcuts

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