pgrunner

package module
v0.0.0-...-6670ed0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

README

Go PGRunner

PGunner: An easy way to run postgres in unit and integration tests, from Docker.

Every call of PGRunner will create a new, private Postgres instance in the local Docker Engine, and expose a unique URL that clients can use to connect to it.

Usage

When using pgrunner from docker, you must run it as root and pass the define the following environment variables:

  • PGRUNNER_TEMP_DIR: "/some/writable/path"
  • PGRUNNER_EXEC_AS_ROOT: "true"

Mount as volume, on the container, a directory which has the same name as the host directory.

Finally, you must make the docker socket available in the container.

For instance, this is an example of docker command used to run the unit tests inside docker:

docker run -it --rm \
    -e PGRUNNER_TEMP_DIR=/tmp/shared \
    -e PGRUNNER_EXEC_AS_ROOT=true \
    -v /var/run/docker.sock:/var/run/docker.sock:rw \
    -v </path/to/pgrunner>:/src:ro \
    -v /some/writable/path/:/some/writable/path/:rw \
    -w /src \    
    golang:latest \
    go test ./...

Similar projects

The best and most widely used alternative for this package is Dockertest, although PGRunner has a much narrower scope and simpler codebase, as it aims to only run Postgres, instead of being a generic way to run docker services from integration tests.

TODO

  • Document it
  • CI/CD stuff
  • Improve API

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context) (_ runner.CancellableRunner, connectionURL string, _ func(context.Context, func(string) error) error, _ error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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