Documentation
¶
Overview ¶
Package testing provides test utilities for the jobqueue package.
Index ¶
- func NewDBForBackend(t testing.TB, backend Backend) *sql.DB
- func NewInMemoryDB(t testing.TB) *sql.DB
- func NewPostgresDB(t testing.TB) *sql.DB
- func NewQ(t testing.TB, opts queue.NewOpts) *queue.Queue
- func NewQForBackend(t testing.TB, opts queue.NewOpts, backend Backend) *queue.Queue
- func PostgresAvailable() bool
- func RunForAllBackends(t *testing.T, fn func(t *testing.T, backend Backend))
- func RunForAllBackendsB(b *testing.B, fn func(b *testing.B, backend Backend))
- func SetupPostgresContainer(ctx context.Context) error
- func TeardownPostgresContainer(ctx context.Context)
- type Backend
- type Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDBForBackend ¶ added in v0.2.3
NewDBForBackend creates a new database connection for the given backend. For SQLite, it creates an in-memory database. For PostgreSQL, it connects to the test container and sets up the schema.
func NewInMemoryDB ¶
NewInMemoryDB creates a new in-memory SQLite database for testing with both classic queue and dedup queue schemas initialized.
func NewPostgresDB ¶ added in v0.2.3
NewPostgresDB creates a new PostgreSQL connection for testing. It skips the test if PostgreSQL is not available.
func NewQForBackend ¶ added in v0.2.3
NewQForBackend creates a new queue using the specified backend for testing.
func PostgresAvailable ¶ added in v0.2.3
func PostgresAvailable() bool
PostgresAvailable returns true if PostgreSQL container is running and available.
func RunForAllBackends ¶ added in v0.2.3
RunForAllBackends runs a test function for each available backend. This creates subtests named "sqlite" and "postgres".
func RunForAllBackendsB ¶ added in v0.2.3
RunForAllBackendsB runs a benchmark function for each available backend.
func SetupPostgresContainer ¶ added in v0.2.3
SetupPostgresContainer initializes the PostgreSQL container. Call this from TestMain to set up the container once for all tests in a package.
func TeardownPostgresContainer ¶ added in v0.2.3
TeardownPostgresContainer terminates the PostgreSQL container. Call this from TestMain after m.Run() completes.
Types ¶
type Backend ¶ added in v0.2.3
type Backend string
Backend represents a database backend for testing.
func AllBackends ¶ added in v0.2.3
func AllBackends() []Backend
AllBackends returns all available backends for testing. PostgreSQL is excluded if not available (container not running or skipped).
func (Backend) IsPostgres ¶ added in v0.2.3
IsPostgres returns true if this is the PostgreSQL backend.