component

package
v0.0.0-...-edfa39e Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2019 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 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 {
	NewComponent(d Descriptor, scope lifecycle.Scope) (Instance, error)
	NewComponentOrFail(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 ID, or null if not found.
	GetComponent(id ID) Instance
	GetComponentOrFail(id ID, t testing.TB) Instance

	// Gets the component matching the given descriptor, or null if not found.
	GetComponentForDescriptor(d Descriptor) Instance
	GetComponentForDescriptorOrFail(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 to 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