testcontainerpostgres

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: Apache-2.0, Unlicense Imports: 4 Imported by: 0

README

Postgres testcontainer

A postgres docker testcontainer for go

Example usage:

initPath, err := filepath.Abs("./fixtures")
if err != nil {
    log.Fatalf("%v", err)
}
ctx := context.Background()
postgresC, conn, err := postgrestestcontainer.New(ctx, "14.5-alpine", initPath)
if err != nil {
    log.Fatalf("%v", err)
}
defer Terminate(ctx, postgresC)

fmt.Println(conn)
// Output: postgres://postgres:postgres@localhost:49156/test_db

Run tests

go test

Documentation

Overview

Package testcontainerpostgres provides an easy way to start a postgres testcontainer using docker

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, tag, init string) (testcontainers.Container, string, error)

New setup a postgres testcontainer

func Terminate

func Terminate(ctx context.Context, c testcontainers.Container)

Terminate terminates the container in a defer friendly way

Types

This section is empty.

Jump to

Keyboard shortcuts

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