stdpgtest

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2025 License: MIT Imports: 11 Imported by: 1

Documentation

Overview

Package stdpgtest provides testing against a postgresql database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPgxTestDB

func NewPgxTestDB(
	tb testing.TB,
	migrator pgtestdb.Migrator,
	setupConnStr string,
	testRole *pgtestdb.Role,
) *pgtestdb.Config

NewPgxTestDB will use the pgtestdb package to migrate, creates a isolated database and returns the connection string to that database..

func SetupPgxPool

func SetupPgxPool(ctx context.Context, tb testing.TB, snapshotFile, connString string) *pgxpool.Pool

SetupPgxPool will init a isolated test database from a connection string and a snapshot sql file.

Types

type SnapshotMigrater

type SnapshotMigrater[T interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}] string

SnapshotMigrater loads a migration from a postgres dump file.

func (SnapshotMigrater[T]) Hash

func (m SnapshotMigrater[T]) Hash() (string, error)

Hash implements the migrater interface.

func (SnapshotMigrater[T]) Migrate

func (m SnapshotMigrater[T]) Migrate(ctx context.Context, db T, _ pgtestdb.Config) error

Migrate performs the actual migration.

Jump to

Keyboard shortcuts

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