pgtest

package
v0.0.0-...-1a642c0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CleanupFunc

type CleanupFunc func()

CleanupFunc deletes the schema and all database objects.

func NewPostgresSchema

func NewPostgresSchema(t *testing.T, sqlFiles []string, opts ...Option) (*pgx.Conn, CleanupFunc)

NewPostgresSchema opens a connection with search_path set to a randomly named, new schema and loads all sqlFiles.

func NewPostgresSchemaString

func NewPostgresSchemaString(t *testing.T, sql string, opts ...Option) (*pgx.Conn, CleanupFunc)

NewPostgresSchemaString opens a connection with search_path set to a randomly named, new schema and loads the sql string.

type GuardedStmtCache

type GuardedStmtCache struct {
	*stmtcache.LRU
	// contains filtered or unexported fields
}

GuardedStmtCache errors if any name in names is used to get a cached statement. Allows verifying that PrepareAllQueries works by creating prepared statements ahead of time. pgx accesses a map of prepared statements directly rather than calling Get.

func NewGuardedStmtCache

func NewGuardedStmtCache(conn *pgconn.PgConn, names ...string) *GuardedStmtCache

func (*GuardedStmtCache) Get

type Option

type Option func(config *pgx.ConnConfig)

func WithGuardedStmtCache

func WithGuardedStmtCache(names ...string) Option

WithGuardedStmtCache is a functional option to initialize a the pgtest conn with a guarded cache that fails if pgx attempts to cache any SQL query in names. The names are typically SQL statements.

Jump to

Keyboard shortcuts

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