testutils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package testutils provides test helpers for asynqpg integration tests. This package is for testing only and should not be considered stable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyReadyNotifications added in v0.2.0

func ApplyReadyNotifications(t testing.TB, db *sqlx.DB)

ApplyReadyNotifications installs LEGACY triggers for upgrade tests only. Normal notification tests and production deployments need no trigger installation.

func NotificationPool added in v0.2.0

func NotificationPool(t testing.TB, dsn string) *pgxadapter.Pool

NotificationPool connects a test adapter to the fixture database.

func SetupTestDatabase

func SetupTestDatabase(t *testing.T) *sqlx.DB

SetupTestDatabase creates a PostgreSQL test container and returns a connected *sqlx.DB.

func SetupTestDatabaseWithConnStr

func SetupTestDatabaseWithConnStr(t *testing.T) (*sqlx.DB, string)

SetupTestDatabaseWithConnStr returns both the sqlx.DB and the raw connection string. Useful for tests that need to open additional connections (e.g., via sql.Open or pgx).

func SetupTestDatabaseWithImage added in v0.2.0

func SetupTestDatabaseWithImage(t *testing.T, image string) (*sqlx.DB, string)

SetupTestDatabaseWithImage creates a test database using an explicit PostgreSQL image.

Types

type Task

type Task struct {
	ID               int64          `db:"id"`
	Type             string         `db:"type"`
	IdempotencyToken *string        `db:"idempotency_token"`
	Payload          []byte         `db:"payload"`
	Status           string         `db:"status"`
	Messages         pq.StringArray `db:"messages"`
	BlockedTill      time.Time      `db:"blocked_till"`
	AttemptsLeft     int            `db:"attempts_left"`
	AttemptsElapsed  int            `db:"attempts_elapsed"`
}

Task is a simplified representation of an asynqpg task for test assertions.

func GetTaskByIdempotencyToken

func GetTaskByIdempotencyToken(t *testing.T, db *sqlx.DB, token string) (*Task, error)

GetTaskByIdempotencyToken retrieves a task by its idempotency token for test assertions.

Jump to

Keyboard shortcuts

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