Documentation
¶
Index ¶
- Constants
- Variables
- func IsInsideContainer() bool
- func RunMigrationContainer(mysql *MySQLContainer, options MigrationOptions) error
- func ToMySQLConnectionString(options MySQLOptions) (string, error)
- type Container
- func (c *Container) IPAddress() string
- func (c *Container) OnReady(initializer ContainerCallback)
- func (c *Container) Run() error
- func (c *Container) SetEnvVars(envs []string) *Container
- func (c *Container) SetHealthChecker(checker ContainerCallback) *Container
- func (c *Container) SetInitializer(initializer ContainerCallback) *Container
- func (c *Container) Start() error
- func (c *Container) Stop() error
- func (c *Container) Suspend() error
- func (c *Container) Wait() error
- type ContainerCallback
- type DynamodbContainer
- type DynamodbOptions
- type Etcdcontainer
- type MigrationOptions
- type MySQLContainer
- type MySQLOptions
- type Option
- func DockerEnv(env []string) Option
- func ExposePorts(ports ...string) Option
- func HealthChecker(checker ContainerCallback) Option
- func HostPortBindings(bindings ...PortBinding) Option
- func ImageRepository(name string) Option
- func ImageTag(tag string) Option
- func Initializer(init ContainerCallback) Option
- func Name(name string) Option
- func Ports(ports ...int) Option
- func RunOptions(args []string) Option
- type PortBinding
- type RabbitMQContainer
- type RedisContainer
Constants ¶
const DefaultDynamodbPort = "8000"
Variables ¶
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 (*Container) OnReady ¶ added in v1.0.4
func (c *Container) OnReady(initializer ContainerCallback)
func (*Container) SetEnvVars ¶ added in v1.0.4
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
type ContainerCallback ¶ added in v1.0.4
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
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 ExposePorts ¶ added in v1.0.4
func HealthChecker ¶
func HealthChecker(checker ContainerCallback) Option
func HostPortBindings ¶ added in v1.0.4
func HostPortBindings(bindings ...PortBinding) Option
func ImageRepository ¶
func Initializer ¶
func Initializer(init ContainerCallback) Option
func RunOptions ¶
type PortBinding ¶ added in v1.0.4
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