worker.v1: gopkg.in/juju/worker.v1/dependency/testing Index | Files

package testing

import "gopkg.in/juju/worker.v1/dependency/testing"

Index

Package Files

stub.go

type Context Uses

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

Context implements dependency.Context for convenient testing of dependency.StartFuncs.

func StubContext Uses

func StubContext(abort <-chan struct{}, raw map[string]interface{}) *Context

StubContext returns a Context backed by abort and resources derived from raw.

func (*Context) Abort Uses

func (ctx *Context) Abort() <-chan struct{}

Abort is part of the dependency.Context interface.

func (*Context) Get Uses

func (ctx *Context) Get(name string, outPtr interface{}) error

Get is part of the dependency.Context interface.

type StubResource Uses

type StubResource struct {
    Outputs []interface{}
    Error   error
}

StubResource is used to define the behaviour of a StubGetResource func for a particular resource name.

func NewStubResource Uses

func NewStubResource(outputs ...interface{}) StubResource

NewStubResource creates a single StubResource with the given outputs. (If you need to specify an error result, use the StubResource type directly.)

type StubResources Uses

type StubResources map[string]StubResource

StubResources defines the complete behaviour of a StubGetResource func.

func NewStubResources Uses

func NewStubResources(raw map[string]interface{}) StubResources

NewStubResources converts raw into a StubResources by assuming that any non-error value is intended to be an output. Multiple outputs can set by specifying a slice of interface{}s.

func (StubResources) Context Uses

func (resources StubResources) Context() dependency.Context

Context returns a dependency.Context that never aborts, backed by resources.

Package testing imports 5 packages (graph) and is imported by 2 packages. Updated 2019-10-23. Refresh now. Tools for package owners.