postgrestest

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pod

type Pod struct {
	// contains filtered or unexported fields
}

Pod is a test component for running a Postgres docker instance.

func NewPod

func NewPod(ctx context.Context, opts ...PodOption) (Pod, error)

NewPod creates a new Postgres test container instance.

It accepts options to configure the image tag, database name, and migrations filesystem.

If migrations are provided, they will be executed after the container is started.

If seed data is provided, it will be executed after the migrations using transactions to ensure operation atomicity.

func (Pod) Client

func (p Pod) Client() *sql.DB

Client returns the SQL client for the Postgres container.

func (Pod) Close

func (p Pod) Close() error

Close terminates the Postgres container and closes the SQL client connection.

type PodOption

type PodOption func(*podOptions)

func WithPodDatabaseName

func WithPodDatabaseName(databaseName string) PodOption

WithPodDatabaseName sets the database name for the Postgres container.

func WithPodImageTag

func WithPodImageTag(imageTag string) PodOption

WithPodImageTag sets the image tag for the Postgres container.

func WithPodMigrationsFS

func WithPodMigrationsFS(fs fs.FS) PodOption

WithPodMigrationsFS sets the filesystem for migrations.

func WithPodSeedFS

func WithPodSeedFS(fs fs.FS) PodOption

WithPodSeedFS sets the filesystem for seed data.

Jump to

Keyboard shortcuts

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