testutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMySQLContainer

func NewMySQLContainer(t *testing.T, serviceName string, schemaFiles ...string) *sql.DB

NewMySQLContainer starts a named MariaDB container for the given service, applies the given schema files, and returns a *sql.DB connection.

The container is named "osdbe-test-<serviceName>" so it's easy to identify via `docker ps`. The container is cleaned up automatically when the test ends.

func SeedSQL

func SeedSQL(t *testing.T, db *sql.DB, statements ...string)

SeedSQL executes raw SQL statements against the database. Multiple statements can be separated by semicolons.

func SkipIfNoDocker

func SkipIfNoDocker(t *testing.T)

SkipIfNoDocker skips the test if Docker is not available.

Types

type MySQLContainerResult

type MySQLContainerResult struct {
	DB  *sql.DB
	URL string // oslo.db format, e.g. mysql+pymysql://test:test@host:port/testdb
	// contains filtered or unexported fields
}

MySQLContainerResult holds a database connection and oslo.db-format URL returned by NewMySQLContainerWithURL.

func NewMySQLContainerWithURL

func NewMySQLContainerWithURL(t *testing.T, serviceName string, schemaFiles ...string) MySQLContainerResult

NewMySQLContainerWithURL is like NewMySQLContainer but also returns an oslo.db-format connection URL suitable for passing to collector.Config.

func (MySQLContainerResult) Terminate

func (r MySQLContainerResult) Terminate(ctx context.Context) error

Terminate stops and removes the underlying MariaDB container. This is useful for testing resilience when a database becomes unavailable.

Jump to

Keyboard shortcuts

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