componenttest

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package componenttest provides utilities for testing 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

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

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

type TestFailModule

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

func (*TestFailModule) Run

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

func (*TestFailModule) Update

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

func (*TestFailModule) UpdateContent

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