component

package
v0.0.0-...-fe632b3 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration fmt.Stringer

Configuration is a marker interface for configuration objects that components take.

type ConfiguredRequirement

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

A configured requirement contains the requirement, a configuration object, and the name to give that configured object.

func NewConfiguredRequirement

func NewConfiguredRequirement(name string, requirement Requirement, config Configuration) *ConfiguredRequirement

Creates a named requirement that includes configuration.

func NewNamedRequirement

func NewNamedRequirement(name string, requirement Requirement) *ConfiguredRequirement

Creates a new named requirement without configuration.

func (*ConfiguredRequirement) GetConfiguration

func (c *ConfiguredRequirement) GetConfiguration() Configuration

func (*ConfiguredRequirement) GetName

func (c *ConfiguredRequirement) GetName() string

func (*ConfiguredRequirement) GetRequirement

func (c *ConfiguredRequirement) GetRequirement() Requirement

func (ConfiguredRequirement) String

func (c ConfiguredRequirement) String() string

type Defaults

type Defaults interface {
	GetDefaultDescriptor(id ID) (Descriptor, error)
	GetDefaultDescriptorOrFail(id ID, t testing.TB) Descriptor
}

Defaults provides default component Descriptors for components.

type Descriptor

type Descriptor struct {
	ID
	IsSystemComponent bool
	Variant           Variant
	Requires          []Requirement
}

Descriptor describes a component of the testing framework.

func (Descriptor) FriendlyName

func (d Descriptor) FriendlyName() string

FriendlyName provides a brief one-liner containing ID and Variant. Useful for error messages.

func (*Descriptor) String

func (d *Descriptor) String() string

type Factory

type Factory interface {

	// Creates a new component with the given descriptor and scope. The name parameter may be used
	// to create multiple instances of a single descriptor, if multiple are not needed use "".
	NewComponent(name string, d Descriptor, scope lifecycle.Scope) (Instance, error)

	// Creates a new component with the given descriptor and scope, failing if the component cannot
	// be created. The name parameter may be used to create multiple instances of a single descriptor.
	NewComponentOrFail(name string, d Descriptor, scope lifecycle.Scope, t testing.TB) Instance
}

Factory for new component instances

type ID

type ID string

ID for a component of the testing framework

func (*ID) String

func (id *ID) String() string

type Instance

type Instance interface {
	Descriptor() Descriptor
	Scope() lifecycle.Scope
}

Instance of a testing framework component

type Repository

type Repository interface {
	// Gets the component with the given name and ID, or null if not found. Name may be empty if the
	// default component for the ID should be returned.
	GetComponent(name string, id ID) Instance
	GetComponentOrFail(name string, id ID, t testing.TB) Instance

	// Gets the component matching the given name and descriptor, or null if not found. Name may be
	// empty if the default component for the descriptor should be returned.
	GetComponentForDescriptor(name string, d Descriptor) Instance
	GetComponentForDescriptorOrFail(name string, d Descriptor, t testing.TB) Instance

	// Gets all components currently active in the system.
	GetAllComponents() []Instance
}

Repository of components.

type Requirement

type Requirement fmt.Stringer

Requirement is a marker interface for an element that can be required of the testing framework.

type RequirementError

type RequirementError interface {
	error

	// IsStartError indicates that the error occurred while starting a component. Otherwise the error was related to
	// resolving the dependency chain of a required component
	IsStartError() bool
}

RequirementError is an error that occurred while requiring components.

type Resolver

type Resolver interface {
	// Require the given components to be available with the given lifecycle scope. The components may be specified
	// via ID or specifically by descriptor. If a component requires others, each of its required components are
	// implicitly required with the same scope. If a component already exists with the requested scope (or higher),
	// the existing component is used.
	Require(scope lifecycle.Scope, reqs ...Requirement) RequirementError

	// RequireOrFail calls Require and fails the test if any error occurs.
	RequireOrFail(t testing.TB, scope lifecycle.Scope, reqs ...Requirement)

	// RequireOrSkip calls Require and skips the test if a non-start RequirementError occurs. If a start error occurs,
	// however, the test still fails.
	RequireOrSkip(t testing.TB, scope lifecycle.Scope, reqs ...Requirement)
}

Resolver for component requirements. It controls creation of the dependency tree for each required component.

type Variant

type Variant string

Variant allows an environment to support multiple components with the same ID. For example, an environment might support two Widget components: "fake widget" and "real widget".

Jump to

Keyboard shortcuts

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