Documentation
¶
Overview ¶
Package componenttest provides utilities for testing Flow components.
Index ¶
- func TestContext(t *testing.T) context.Context
- type Controller
- func (c *Controller) Exports() component.Exports
- func (c *Controller) Run(ctx context.Context, args component.Arguments) error
- func (c *Controller) Update(args component.Arguments) error
- func (c *Controller) WaitExports(timeout time.Duration) error
- func (c *Controller) WaitRunning(timeout time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestContext ¶
func TestContext(t *testing.T) 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 (*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.