testpostgres

package
v0.0.0-...-96860c4 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustRun

func MustRun(opts ...options.Option) *testsql.Container

MustRun is the same as Run except it panics on error.

func Run

func Run(opts ...options.Option) (*testsql.Container, error)

Run creates and starts a docker Container with the `postgres` image. Defaults to `postgres:latest` if no option sets image tag. A default context is used with a timeout of two minutes. To customize use RunWithContext.

func RunForTest

func RunForTest(t *testing.T, opts ...options.Option) *testsql.Container

RunForTest creates and starts a docker Container with the `postgres` image. Defaults to `postgres:latest` if no option sets image tag. The Container is automatically terminated after the test has finished. A default context is used with a timeout of two minutes. To customize use RunTestWithContext.

func RunForTestWithContext

func RunForTestWithContext(t *testing.T, ctx context.Context, opts ...options.Option) *testsql.Container

RunForTestWithContext creates and starts a docker Container with the `postgres` image. Defaults to `latest` if no option sets image tag. A context can be provided to configure things such as timeout. The Container is automatically terminated after the test has finished.

func RunWithContext

func RunWithContext(ctx context.Context, opts ...options.Option) (con *testsql.Container, err error)

RunWithContext creates and starts a docker Container with the `postgres` image. Defaults to `postgres:latest` if no option sets image tag. A context can be provided to configure things such as timeout.

func WithInitialDatabase

func WithInitialDatabase(dbName string) options.Option

WithInitialDatabase sets POSTGRES_DB

func WithPassword

func WithPassword(password string) options.Option

WithPassword sets POSTGRES_PASSWORD to the given password.

func WithTrust

func WithTrust() options.Option

func WithUser

func WithUser(user string) options.Option

WithUser sets POSTGRES_USER to the given username.

Types

This section is empty.

Jump to

Keyboard shortcuts

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