test

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultDynamodbPort = "8000"

Variables

View Source
var DefaultMySQLOptions = MySQLOptions{
	Username: "root",
	Password: "my-secret-pw",

	Port: "3307",

	Database: "db0",

	Host: "",
}

Functions

func IsInsideContainer added in v1.0.4

func IsInsideContainer() bool

func RunMigrationContainer added in v1.0.4

func RunMigrationContainer(mysql *MySQLContainer, options MigrationOptions) error

RunMigrationContainer creates the migration container and connects to the mysql database to run the migration scripts.

func ToMySQLConnectionString added in v1.0.4

func ToMySQLConnectionString(options MySQLOptions) (string, error)

Convert mysql options to mysql string

Types

type Container

type Container struct {
	Started bool
	// contains filtered or unexported fields
}

func NewDockerContainer

func NewDockerContainer(opts ...Option) *Container

func (*Container) IPAddress added in v1.0.4

func (c *Container) IPAddress() string

IPAddress returns the IP adress of the container.

func (*Container) OnReady added in v1.0.4

func (c *Container) OnReady(initializer ContainerCallback)

func (*Container) Run added in v1.0.4

func (c *Container) Run() error

func (*Container) SetEnvVars added in v1.0.4

func (c *Container) SetEnvVars(envs []string) *Container

func (*Container) SetHealthChecker added in v1.0.4

func (c *Container) SetHealthChecker(checker ContainerCallback) *Container

func (*Container) SetInitializer added in v1.0.4

func (c *Container) SetInitializer(initializer ContainerCallback) *Container

func (*Container) Start

func (c *Container) Start() error

func (*Container) Stop

func (c *Container) Stop() error

func (*Container) Suspend

func (c *Container) Suspend() error

func (*Container) Wait

func (c *Container) Wait() error

type ContainerCallback added in v1.0.4

type ContainerCallback func(*Container) error

func NewDynamodbHealthChecker added in v1.0.4

func NewDynamodbHealthChecker(options DynamodbOptions) ContainerCallback

func NewMySQLHealthChecker added in v1.0.4

func NewMySQLHealthChecker(options MySQLOptions) ContainerCallback

type DynamodbContainer added in v1.0.4

type DynamodbContainer struct {
	*Container
	Options  DynamodbOptions
	Endpoint string
}

func NewDynamodbContainer added in v1.0.4

func NewDynamodbContainer(options DynamodbOptions, containerOptions ...Option) (*DynamodbContainer, error)

func SetupDynamodb added in v1.0.4

func SetupDynamodb() (*DynamodbContainer, error)

func (*DynamodbContainer) Start added in v1.0.4

func (c *DynamodbContainer) Start() error

func (*DynamodbContainer) Teardown added in v1.0.4

func (container *DynamodbContainer) Teardown() error

type DynamodbOptions added in v1.0.4

type DynamodbOptions struct {
	Host   string
	Port   string
	Region string
}

func LoadDynamodbOptions added in v1.0.4

func LoadDynamodbOptions() DynamodbOptions

LoadDynamodbOptions returns the dynamodb options that will be used for the test cases to connect to.

func (DynamodbOptions) Endpoint added in v1.0.4

func (o DynamodbOptions) Endpoint() string

func (DynamodbOptions) MustNewSession added in v1.0.4

func (o DynamodbOptions) MustNewSession() *session.Session

func (*DynamodbOptions) UpdateHostFromContainer added in v1.0.4

func (o *DynamodbOptions) UpdateHostFromContainer(c *Container) error

UpdateHostFromContainer updates the mysql host field according to the current environment

If we're inside the container, we need to override the hostname defined in the option. If not, we should use the default value 127.0.0.1 because we will need to connect to the host port. please note that the TEST_MYSQL_HOST can be overridden.

type Etcdcontainer

type Etcdcontainer struct {
	URL string
	// contains filtered or unexported fields
}

func NewEtcdContainer

func NewEtcdContainer() (*Etcdcontainer, error)

func (*Etcdcontainer) Start

func (container *Etcdcontainer) Start() error

func (*Etcdcontainer) Stop

func (container *Etcdcontainer) Stop() error

func (*Etcdcontainer) Suspend

func (container *Etcdcontainer) Suspend() error

type MigrationOptions added in v1.0.4

type MigrationOptions struct {
	ImageRepository string
	ImageTag        string

	// this command will override the default command.
	// "bundle" "exec" "rake" "db:migrate"
	Command []string
}

MigrationOptions for mysql migration container

type MySQLContainer

type MySQLContainer struct {
	*Container
	Options MySQLOptions
	URL     string
}

func NewMySQLContainer

func NewMySQLContainer(options MySQLOptions, containerOptions ...Option) (*MySQLContainer, error)

func SetupMySQL added in v1.0.4

func SetupMySQL() (*MySQLContainer, error)

setup the mysql connection if TEST_MYSQL_HOST is defined, then we will use the connection directly. if not, a mysql container will be started

func (*MySQLContainer) Start

func (container *MySQLContainer) Start() error

func (*MySQLContainer) Teardown added in v1.0.4

func (container *MySQLContainer) Teardown() error

type MySQLOptions added in v1.0.4

type MySQLOptions struct {
	// The following options are used in the connection string and the mysql server container itself.
	Username string
	Password string
	Port     string
	Database string

	// The host address that will be used to build the connection string
	Host string
}

func LoadMySQLOptions added in v1.0.4

func LoadMySQLOptions() MySQLOptions

LoadMySQLOptions returns the mysql options that will be used for the test cases to connect to.

func (*MySQLOptions) UpdateHostFromContainer added in v1.0.4

func (o *MySQLOptions) UpdateHostFromContainer(c *Container) error

UpdateHostFromContainer updates the mysql host field according to the current environment

If we're inside the container, we need to override the hostname defined in the option. If not, we should use the default value 127.0.0.1 because we will need to connect to the host port. please note that the TEST_MYSQL_HOST can be overridden.

type Option

type Option func(*Container)

func DockerEnv

func DockerEnv(env []string) Option

func ExposePorts added in v1.0.4

func ExposePorts(ports ...string) Option

func HealthChecker

func HealthChecker(checker ContainerCallback) Option

func HostPortBindings added in v1.0.4

func HostPortBindings(bindings ...PortBinding) Option

func ImageRepository

func ImageRepository(name string) Option

func ImageTag

func ImageTag(tag string) Option

func Initializer

func Initializer(init ContainerCallback) Option

func Name

func Name(name string) Option

func Ports

func Ports(ports ...int) Option

Ports function automatically combines port bindings and exposes ports of the container

func RunOptions

func RunOptions(args []string) Option

type PortBinding added in v1.0.4

type PortBinding struct {
	ContainerPort string
	HostPort      string
}

type RabbitMQContainer

type RabbitMQContainer struct {
	URL string
	// contains filtered or unexported fields
}

func NewRabbitMQContainer

func NewRabbitMQContainer() (*RabbitMQContainer, error)

func (*RabbitMQContainer) Start

func (container *RabbitMQContainer) Start() error

func (*RabbitMQContainer) Stop

func (container *RabbitMQContainer) Stop() error

func (*RabbitMQContainer) Suspend

func (container *RabbitMQContainer) Suspend() error

type RedisContainer

type RedisContainer struct {
	URL string
	// contains filtered or unexported fields
}

func NewRedisContainer

func NewRedisContainer() (*RedisContainer, error)

func (*RedisContainer) Start

func (container *RedisContainer) Start() error

func (*RedisContainer) Stop

func (container *RedisContainer) Stop() error

func (*RedisContainer) Suspend

func (container *RedisContainer) Suspend() error

Jump to

Keyboard shortcuts

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