testing

package
v0.0.0-...-0a271de Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: AGPL-3.0 Imports: 18 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IsAtomicContextChecker = gomock.AssignableToTypeOf(domain.AtomicContext(&testingAtomicContext{}))

IsAtomicContextChecker is a gomock.Matcher that checks if the argument is an AtomicContext.

Functions

func NewAtomicContext

func NewAtomicContext(ctx context.Context) *testingAtomicContext

NewAtomicContext returns a stub implementation of domain.AtomicContext. Used for testing.

func NoopLeaderEnsurer

func NoopLeaderEnsurer() leadership.Ensurer

NoopLeaderEnsurer returns a leadership.Ensurer that will always allow leadership to be taken and held.

func SeedControllerConfig

func SeedControllerConfig(
	c *gc.C,
	config controller.Config,
	controllerModelUUID coremodel.UUID,
	provider ControllerTxnProvider,
) controller.Config

Types

type ControllerTxnProvider

type ControllerTxnProvider interface {
	ControllerTxnRunner() coredatabase.TxnRunner
}

type NamespaceWatcherFactory

type NamespaceWatcherFactory struct {
	InitialStateFunc func() ([]string, error)
	WatcherChans     map[string]chan []string
}

NamespaceWatcherFactory implements a simple NamespaceWatcher creation process for tests. It supports channels of changes on to multiple namespaces. Channels created on this factory are buffered by 1 slot. This means that data needs to be consumed from the watcher before the next lot of data is placed to avoid a single goroutine lock.

func NewNamespaceWatcherFactory

func NewNamespaceWatcherFactory(initial func() ([]string, error)) *NamespaceWatcherFactory

NewNamespaceWatcherFactory constructs a new NamespaceWatchFactory with a func that can provide initial state into newly minted watchers. initial func can be nil in which cash no initial state will be supplied to watchers.

func (*NamespaceWatcherFactory) Close

func (f *NamespaceWatcherFactory) Close()

Close must be called after using this factory to safely clean up all the channels.

func (*NamespaceWatcherFactory) FeedChange

func (f *NamespaceWatcherFactory) FeedChange(
	ctx context.Context,
	namespace string,
	_ changestream.ChangeType,
	change []string,
) error

FeedChange feeds the supplied change for the given namespace into any watchers that are open. If no watchers exist this func call evaluates to a noop. FeedChange will block until the watches channel can accept the data or the context is canceled.

func (*NamespaceWatcherFactory) NewNamespaceWatcher

func (f *NamespaceWatcherFactory) NewNamespaceWatcher(
	namespace string,
	changeMask changestream.ChangeType,
	initialStateQuery eventsource.NamespaceQuery,
) (watcher.StringsWatcher, error)

NewNamespaceWatcher implements WatcherFactory.NewNamespaceWatcher

Jump to

Keyboard shortcuts

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