dockertest

package
v0.0.0-...-bb3e6dd Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2016 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package dockertest contains helper functions for setting up and tearing down docker containers to aid in testing.

Index

Constants

View Source
const (
	MySQLUsername = "root"
	MySQLPassword = "root"

	PostgresUsername = "docker" // set up by the dockerfile of postgresImage
	PostgresPassword = "docker" // set up by the dockerfile of postgresImage
)

Variables

This section is empty.

Functions

func AwaitReachable

func AwaitReachable(addr string, maxWait time.Duration) error

AwaitReachable tries to make a TCP connection to addr regularly. It returns an error if it's unable to make a connection before maxWait.

func IP

func IP(containerID string) (string, error)

IP returns the IP address of the container.

func KillContainer

func KillContainer(container string) error

func Pull

func Pull(image string) error

Pull retrieves the docker image with 'docker pull'.

Types

type ContainerID

type ContainerID string

func SetupMongoContainer

func SetupMongoContainer(t *testing.T) (c ContainerID, ip string)

SetupMongoContainer sets up a real MongoDB instance for testing purposes, using a Docker container. It returns the container ID and its IP address, or makes the test fail on error. Currently using https://hub.docker.com/_/mongo/

func SetupMySQLContainer

func SetupMySQLContainer(t *testing.T, dbname string) (c ContainerID, ip string)

SetupMySQLContainer sets up a real MySQL instance for testing purposes, using a Docker container. It returns the container ID and its IP address, or makes the test fail on error. Currently using https://hub.docker.com/_/mysql/

func SetupPostgreSQLContainer

func SetupPostgreSQLContainer(t *testing.T, dbname string) (c ContainerID, ip string)

SetupPostgreSQLContainer sets up a real PostgreSQL instance for testing purposes, using a Docker container. It returns the container ID and its IP address, or makes the test fail on error. Currently using https://hub.docker.com/_/postgres/

func (ContainerID) IP

func (c ContainerID) IP() (string, error)

func (ContainerID) Kill

func (c ContainerID) Kill() error

func (ContainerID) KillRemove

func (c ContainerID) KillRemove(t *testing.T)

KillRemove calls Kill on the container, and then Remove if there was no error. It logs any error to t.

func (ContainerID) Remove

func (c ContainerID) Remove() error

Remove runs "docker rm" on the container

Jump to

Keyboard shortcuts

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