testutils

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 11 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 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).

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