Documentation ¶
Index ¶
- func ConstFactory(runner coredatabase.TxnRunner) func() (changestream.WatchableDB, error)
- func DumpTable(c *gc.C, db *sql.DB, table string, extraTables ...string)
- func FindTCPPort(c *gc.C) int
- func SingularDBGetter(runner coredatabase.TxnRunner) coredatabase.DBGetter
- type DqliteSuite
- func (s *DqliteSuite) ApplyDDL(c *gc.C, schema SchemaApplier)
- func (s *DqliteSuite) ApplyDDLForRunner(c *gc.C, schema SchemaApplier, runner coredatabase.TxnRunner)
- func (s *DqliteSuite) DB() *sql.DB
- func (s *DqliteSuite) DBApp() *app.App
- func (s *DqliteSuite) DBPath() string
- func (s *DqliteSuite) NoopTxnRunner() coredatabase.TxnRunner
- func (s *DqliteSuite) OpenDB(c *gc.C) (coredatabase.TxnRunner, *sql.DB)
- func (s *DqliteSuite) OpenDBForNamespace(c *gc.C, domain string, foreignKey bool) (coredatabase.TxnRunner, *sql.DB)
- func (s *DqliteSuite) RootPath() string
- func (s *DqliteSuite) SetUpTest(c *gc.C)
- func (s *DqliteSuite) TearDownTest(c *gc.C)
- func (s *DqliteSuite) TxnRunner() coredatabase.TxnRunner
- func (s *DqliteSuite) TxnRunnerFactory() func() (coredatabase.TxnRunner, error)
- type SchemaApplier
- type TestTrackedDB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstFactory ¶
func ConstFactory(runner coredatabase.TxnRunner) func() (changestream.WatchableDB, error)
ConstFactory returns a changestream.WatchableDB factory function from just a database.TxnRunner.
func DumpTable ¶
DumpTable dumps the contents of the given table to stdout. This is useful for debugging tests. It is not intended for use in production code.
func FindTCPPort ¶
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.
func SingularDBGetter ¶
func SingularDBGetter(runner coredatabase.TxnRunner) coredatabase.DBGetter
SingularDBGetter returns a DBGetter that always returns the given database.
Types ¶
type DqliteSuite ¶
type DqliteSuite struct { testing.IsolationSuite // Verbose indicates whether the suite should print all the sql // hitting the db. Verbose bool // UseTCP when true, SetUpTest will use a random TCP port. // When false, it will use a random UNIX abstract domain socket. UseTCP bool // contains filtered or unexported fields }
DqliteSuite is used to provide a sql.DB reference to tests. It is not pre-populated with any schema and is the job the users of this Suite to call ApplyDDL after SetupTest has been called.
func (*DqliteSuite) ApplyDDL ¶
func (s *DqliteSuite) ApplyDDL(c *gc.C, schema SchemaApplier)
ApplyDDL is a helper manager for the test suites to apply a set of DDL string on top of a pre-established database.
func (*DqliteSuite) ApplyDDLForRunner ¶
func (s *DqliteSuite) ApplyDDLForRunner(c *gc.C, schema SchemaApplier, runner coredatabase.TxnRunner)
ApplyDDLForRunner is a helper manager for the test suites to apply a set of DDL string on top of a pre-established database.
func (*DqliteSuite) DBPath ¶
func (s *DqliteSuite) DBPath() string
DBPath returns the path to the dqlite database.
func (*DqliteSuite) NoopTxnRunner ¶
func (s *DqliteSuite) NoopTxnRunner() coredatabase.TxnRunner
NoopTxnRunner returns a no-op transaction runner. Each call to this function will return the same instance, which will return a not implemented error when used.
func (*DqliteSuite) OpenDB ¶
func (s *DqliteSuite) OpenDB(c *gc.C) (coredatabase.TxnRunner, *sql.DB)
OpenDB returns a new sql.DB reference.
func (*DqliteSuite) OpenDBForNamespace ¶
func (s *DqliteSuite) OpenDBForNamespace(c *gc.C, domain string, foreignKey bool) (coredatabase.TxnRunner, *sql.DB)
OpenDBForNamespace returns a new sql.DB reference for the domain.
func (*DqliteSuite) RootPath ¶
func (s *DqliteSuite) RootPath() string
RootPath returns the root path for the dqlite database.
func (*DqliteSuite) SetUpTest ¶
func (s *DqliteSuite) SetUpTest(c *gc.C)
SetUpTest creates a new sql.DB reference and ensures that the controller schema is applied successfully.
func (*DqliteSuite) TearDownTest ¶
func (s *DqliteSuite) TearDownTest(c *gc.C)
TearDownTest is responsible for cleaning up the testing resources created with the ControllerSuite
func (*DqliteSuite) TxnRunner ¶
func (s *DqliteSuite) TxnRunner() coredatabase.TxnRunner
TxnRunner returns the suite's transaction runner.
func (*DqliteSuite) TxnRunnerFactory ¶
func (s *DqliteSuite) TxnRunnerFactory() func() (coredatabase.TxnRunner, error)
TxnRunnerFactory returns a DBFactory that returns the given database.
type SchemaApplier ¶
SchemaApplier is an interface that can be used to apply a schema to a database.
type TestTrackedDB ¶
type TestTrackedDB struct {
// contains filtered or unexported fields
}
func NewTestTrackedDB ¶
func NewTestTrackedDB(f coredatabase.TxnRunnerFactory) *TestTrackedDB
NewTestTrackedDB returns a tracked db worker which returns a tracked db attached to the test suite.
func (*TestTrackedDB) Kill ¶
func (t *TestTrackedDB) Kill()
func (*TestTrackedDB) Wait ¶
func (t *TestTrackedDB) Wait() error