testing

package
v0.0.0-...-439fd0a Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindTCPPort

func FindTCPPort(c *gc.C) int

FindTCPPort finds an unused TCP port and returns it. It is prone to racing, so the port should be used as soon as it is acquired to minimise the change of another process using it in the interim. The chances of this should be negligible during testing.

Types

type ControllerSuite

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

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

func (*ControllerSuite) ApplyControllerDDL

func (s *ControllerSuite) ApplyControllerDDL(c *gc.C, db *sql.DB)

ApplyControllerDDL applies the controller schema to the provided sql.DB. This is useful for tests that need to apply the schema to a new DB.

func (*ControllerSuite) DB

func (s *ControllerSuite) DB() *sql.DB

DB returns a sql.DB reference.

func (*ControllerSuite) NewCleanDB

func (s *ControllerSuite) NewCleanDB(c *gc.C) *sql.DB

NewCleanDB returns a new sql.DB reference.

func (*ControllerSuite) SetUpTest

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

SetUpTest creates a new sql.DB reference and ensures that the controller schema is applied successfully.

func (*ControllerSuite) TearDownTest

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

func (*ControllerSuite) TrackedDB

func (s *ControllerSuite) TrackedDB() coredatabase.TrackedDB

TrackedDB returns a TrackedDB reference.

type DBSuite

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

DBSuite is used to provide a Dqlite-backed sql.DB reference to tests.

func (*DBSuite) DB

func (s *DBSuite) DB() *sql.DB

func (*DBSuite) SetUpSuite

func (s *DBSuite) SetUpSuite(c *gc.C)

SetUpSuite creates a new Dqlite application and waits for it to be ready.

func (*DBSuite) SetUpTest

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

SetUpTest opens a new, randomly named database and makes it available for use by test the next test.

func (*DBSuite) TearDownSuite

func (s *DBSuite) TearDownSuite(c *gc.C)

TearDownSuite terminates the Dqlite node, releasing all resources.

func (*DBSuite) TearDownTest

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

TearDownTest closes the database opened in SetUpTest. TODO (manadart 2022-09-12): There is currently no avenue for dropping a DB.

func (*DBSuite) TrackedDB

func (s *DBSuite) TrackedDB() coredatabase.TrackedDB

Jump to

Keyboard shortcuts

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