fxtest

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2017 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lifecycle

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

Lifecycle is a testing spy for fx.Lifecycle. It exposes Start and Stop methods (and some test-specific helpers) so that unit tests can exercise hooks.

func NewLifecycle

func NewLifecycle(t TB) *Lifecycle

NewLifecycle creates a new test lifecycle.

func (*Lifecycle) Append

func (l *Lifecycle) Append(h fx.Hook)

Append registers a new Hook.

func (*Lifecycle) MustStart

func (l *Lifecycle) MustStart()

MustStart calls Start, failing the test if an error is encountered.

func (*Lifecycle) MustStop

func (l *Lifecycle) MustStop()

MustStop calls Stop, failing the test if an error is encountered.

func (*Lifecycle) Start

func (l *Lifecycle) Start() error

Start executes all registered OnStart hooks in order, halting at the first hook that doesn't succeed.

func (*Lifecycle) Stop

func (l *Lifecycle) Stop() error

Stop calls all OnStop hooks whose OnStart counterpart was called, running in reverse order.

If any hook returns an error, execution continues for a best-effort cleanup. Any errors encountered are collected into a single error and returned.

type TB

type TB interface {
	// TODO: Use Logf to implement an fxlog.Logger that doesn't spam the console
	Logf(string, ...interface{})
	Errorf(string, ...interface{})
	FailNow()
}

TB is a subset of the standard library's testing.TB interface. It's satisfied by both *testing.T and *testing.B.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳