cachetest

package
v0.0.0-...-ea3e8b0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplicationChange

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

ApplicationChange returns an ApplicationChange representing the input state application.

func ApplicationEvents

func ApplicationEvents(change interface{}) bool

func BranchEvents

func BranchEvents(change interface{}) bool

func CharmChange

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

CharmChange returns a CharmChange representing the input state charm.

func CharmEvents

func CharmEvents(change interface{}) bool

func ControllerEvents

func ControllerEvents(change interface{}) bool

func MachineChange

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

func MachineEvents

func MachineEvents(change interface{}) bool

func ModelChange

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

ModelChange returns a ModelChange representing the input state model.

func ModelChangeFromState

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

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

func ModelEvents

func ModelEvents(change interface{}) bool

func UnitChange

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

UnitChange returns a UnitChange representing the input state unit.

func UnitEvents

func UnitEvents(change interface{}) bool

Types

type TestController

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

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

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

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

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

func (*TestController) UpdateApplication

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

UpdateApplication updates the input state application in the cache.

func (*TestController) UpdateCharm

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

UpdateCharm updates the input state charm in the cache.

func (*TestController) UpdateMachine

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

UpdateMachine updates the input state machine in the cache.

func (*TestController) UpdateModel

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

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

UpdateUnit updates the input state unit in the cache.

Jump to

Keyboard shortcuts

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