testing

package
v0.0.0-...-56cb166 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ControllerSuite

type ControllerSuite struct {
	testing.ControllerSuite
	// contains filtered or unexported fields
}

ControllerSuite is used to provide a sql.DB reference to tests. It is pre-populated with the controller schema.

func (*ControllerSuite) AssertChangeStreamIdle

func (w *ControllerSuite) AssertChangeStreamIdle(c *gc.C)

AssertChangeStreamIdle returns if and when the change stream is idle. This is useful to ensure that the change stream is not processing any events before running a test.

func (*ControllerSuite) GetWatchableDB

func (s *ControllerSuite) GetWatchableDB(namespace string) (changestream.WatchableDB, error)

GetWatchableDB allows the ControllerSuite to be a WatchableDBGetter

func (*ControllerSuite) SetUpTest

func (s *ControllerSuite) SetUpTest(c *gc.C)

SetUpTest is responsible for setting up a testing database suite initialised with the controller schema.

func (*ControllerSuite) TearDownTest

func (s *ControllerSuite) TearDownTest(c *gc.C)

type ModelSuite

type ModelSuite struct {
	testing.ModelSuite
	// contains filtered or unexported fields
}

ModelSuite is used to provide a sql.DB reference to tests. It is pre-populated with the model schema.

func (*ModelSuite) AssertChangeStreamIdle

func (s *ModelSuite) AssertChangeStreamIdle(c *gc.C)

AssertChangeStreamIdle returns if and when the change stream is idle. This is useful to ensure that the change stream is not processing any events before running a test.

func (*ModelSuite) GetWatchableDB

func (s *ModelSuite) GetWatchableDB(namespace string) (changestream.WatchableDB, error)

GetWatchableDB allows the ModelSuite to be a WatchableDBGetter

func (*ModelSuite) PrimeChangeStream

func (s *ModelSuite) PrimeChangeStream(c *gc.C)

PrimeChangeStream the change stream with some initial data. This ensures that the change stream has some initial data otherwise the upper bound won't be set correctly. The model database has no triggers for the initial model, if this changes, we could remove the need for this. This is only for tests as we depend on the change stream to have at least some data, other wise we can't detect if the change stream is idle.

func (*ModelSuite) SetUpTest

func (s *ModelSuite) SetUpTest(c *gc.C)

SetUpTest is responsible for setting up a testing database suite initialised with the model schema.

func (*ModelSuite) TearDownTest

func (s *ModelSuite) TearDownTest(c *gc.C)

type TestWatchableDB

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

TestWatchableDB creates a watchable DB for running the ChangeStream implementation for use inside of tests. This doesn't use the dependency engine and creates a catacomb for managing the lifecycle of the components.

func NewTestWatchableDB

func NewTestWatchableDB(c *gc.C, id string, db database.TxnRunner) *TestWatchableDB

NewTestWatchableDB creates a test changestream based on the id and runnner.

func (*TestWatchableDB) EventMultiplexer

func (h *TestWatchableDB) EventMultiplexer() *eventmultiplexer.EventMultiplexer

EventMultiplexer returns the underlying event multiplixer from the change stream implementation.

func (*TestWatchableDB) Kill

func (h *TestWatchableDB) Kill()

Kill stops the test change stream.

func (*TestWatchableDB) StdTxn

func (w *TestWatchableDB) StdTxn(ctx context.Context, fn func(context.Context, *sql.Tx) error) error

StdTxn manages the application of a standard library transaction within which the input function is executed. The input context can be used by the caller to cancel this process.

func (*TestWatchableDB) Stream

func (h *TestWatchableDB) Stream() *stream.Stream

Stream returns the underlying changestream stream implementation.

func (*TestWatchableDB) Subscribe

EventSource returns the event source for this worker.

func (*TestWatchableDB) Txn

func (w *TestWatchableDB) Txn(ctx context.Context, fn func(context.Context, *sqlair.TX) error) error

Txn manages the application of a SQLair transaction within which the input function is executed. See https://github.com/canonical/sqlair. The input context can be used by the caller to cancel this process.

func (*TestWatchableDB) Wait

func (h *TestWatchableDB) Wait() error

Wait waits for the test change stream.

Jump to

Keyboard shortcuts

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