juju: github.com/juju/juju/core/cache/cachetest Index | Files

package cachetest

import "github.com/juju/juju/core/cache/cachetest"

Index

Package Files

controller.go eventmatchers.go state.go

func ApplicationChange Uses

func ApplicationChange(c *gc.C, modelUUID string, app *state.Application) cache.ApplicationChange

ApplicationChange returns an ApplicationChange representing the input state application.

func ApplicationEvents Uses

func ApplicationEvents(change interface{}) bool

func BranchEvents Uses

func BranchEvents(change interface{}) bool

func CharmChange Uses

func CharmChange(modelUUID string, ch *state.Charm) cache.CharmChange

CharmChange returns a CharmChange representing the input state charm.

func CharmEvents Uses

func CharmEvents(change interface{}) bool

func MachineChange Uses

func MachineChange(c *gc.C, modelUUID string, machine *state.Machine) cache.MachineChange

func MachineEvents Uses

func MachineEvents(change interface{}) bool

func ModelChange Uses

func ModelChange(c *gc.C, model *state.Model) cache.ModelChange

ModelChange returns a ModelChange representing the input state model.

func ModelChangeFromState Uses

func ModelChangeFromState(c *gc.C, st *state.State) cache.ModelChange

ModelChangeFromState returns a ModelChange representing the current model for the state object.

func ModelEvents Uses

func ModelEvents(change interface{}) bool

func UnitChange Uses

func UnitChange(c *gc.C, modelUUID string, unit *state.Unit) cache.UnitChange

UnitChange returns a UnitChange representing the input state unit.

func UnitEvents Uses

func UnitEvents(change interface{}) bool

type TestController Uses

type TestController struct {
    *cache.Controller
    // contains filtered or unexported fields
}

TestController wraps a cache controller for testing. It allows synchronisation of state objects with the cache without the need for a multi-watcher and cache worker. This is useful when testing with StateSuite; JujuConnSuite sets up a cache worker and multiwatcher to keep the model cache in sync, so direct population using this technique is not necessary.

func NewTestController Uses

func NewTestController(matchers ...func(interface{}) bool) *TestController

NewTestController returns creates and returns a new test controller with an initial set of matchers for receiving cache event notifications. The controller can be instantiated like this in suite/test setups in order to retain a common set of matchers, but `Init` should be called in each test (see below).

func (*TestController) Init Uses

func (tc *TestController) Init(c *gc.C, matchers ...func(interface{}) bool)

Init instantiates the inner cache controller and sets up event synchronisation based on the input matchers. Changes sent to the cache can be waited on by using the `NextChange` method.

NOTE: It is recommended to perform this initialisation in the actual test method rather than `SetupSuite` or `SetupTest` as different gc.C references are supplied to each of those methods.

func (*TestController) NextChange Uses

func (tc *TestController) NextChange(c *gc.C) interface{}

NextChange returns the next change processed by the cache that satisfies a matcher, or fails the test with a time-out.

func (*TestController) SendChange Uses

func (tc *TestController) SendChange(change interface{})

func (*TestController) UpdateApplication Uses

func (tc *TestController) UpdateApplication(c *gc.C, modelUUID string, app *state.Application)

UpdateApplication updates the input state application in the cache.

func (*TestController) UpdateCharm Uses

func (tc *TestController) UpdateCharm(modelUUID string, ch *state.Charm)

UpdateCharm updates the input state charm in the cache.

func (*TestController) UpdateMachine Uses

func (tc *TestController) UpdateMachine(c *gc.C, modelUUID string, machine *state.Machine)

UpdateMachine updates the input state machine in the cache.

func (*TestController) UpdateModel Uses

func (tc *TestController) UpdateModel(c *gc.C, m *state.Model)

UpdateModel updates the current model for the input state in the cache.

func (*TestController) UpdateUnit Uses

func (tc *TestController) UpdateUnit(c *gc.C, modelUUID string, unit *state.Unit)

UpdateUnit updates the input state unit in the cache.

Package cachetest imports 11 packages (graph). Updated 2019-08-23. Refresh now. Tools for package owners.