postgrestestcontainer

package module
v0.0.0-...-82ed058 Latest Latest
Warning

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

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

README

Postgres testcontainer

A postgres docker testcontainer for go

Example usage:

schemaPath, err := filepath.Abs("example_schema.sql")
if err != nil {
    log.Fatalf("%v", err)
}
ctx := context.Background()
postgresC, conn, err := postgrestestcontainer.SetupTestDatabase(ctx, "14.5-alpine", schemaPath)
if err != nil {
    log.Fatalf("%v", err)
}
defer Terminate(ctx, postgresC)

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

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupTestDatabase

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

SetupTestDatabase 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