Documentation ¶
Index ¶
- Constants
- Variables
- func IsDuplicateDatabase(err error) bool
- func IsInsideContainer() bool
- func RunGoMigrationContainer(dbContainer *SQLContainer, options MigrationOptions) error
- func RunMigrationContainer(dbContainer *SQLContainer, options MigrationOptions) error
- func ToPostgresArgs(o SQLOptions) (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
- func NewDynamodbHealthChecker(options DynamodbOptions) ContainerCallback
- func NewMySQLHealthChecker(options SQLOptions) ContainerCallback
- func NewPostgreSQLHealthChecker(options SQLOptions) ContainerCallback
- func NewRedisHealthChecker(options RedisOptions) ContainerCallback
- func NewVaultHealthChecker(options VaultOptions) ContainerCallback
- type DynamodbContainer
- type DynamodbOptions
- type Etcdcontainer
- type MigrationOptions
- type MySQLContainer
- type Option
- func DockerEnv(env []string) Option
- func DockerRunLink(link string) Option
- func Entrypoint(entrypoint []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 ImageTagFromEnv(envName, defaultTag 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 PostgreSQLContainer
- type RabbitMQContainer
- type RedisContainer
- type RedisOptions
- type SQLContainer
- type SQLOptions
- type VaultContainer
- type VaultOptions
Constants ¶
const ( DefaultVaultPort = "8200" DefaultToken = "TEST-DEFAULT-TOKEN" DefaultListenAddr = "0.0.0.0" )
const DefaultDynamodbPort = "8000"
const (
DefaultRedisPort = "6379"
)
const (
// ErrDuplicateDatabase returns if try to create duplicate database
ErrDuplicateDatabase = "42P04"
)
Variables ¶
var DefaultMySQLOptions = SQLOptions{
Driver: "mysql",
Username: "root",
Password: "my-secret-pw",
Port: "3307",
Database: "db0",
Host: "",
}
var DefaultPostgreSQLOptions = SQLOptions{
Driver: "postgres",
Username: "admin",
Password: "12345",
Port: "5433",
Database: "postgres",
Host: "",
}
Functions ¶
func IsDuplicateDatabase ¶ added in v1.0.5
func IsInsideContainer ¶ added in v1.0.4
func IsInsideContainer() bool
func RunGoMigrationContainer ¶ added in v1.0.5
func RunGoMigrationContainer(dbContainer *SQLContainer, options MigrationOptions) error
RunGoMigrationContainer creates the migration container and connects to the sql database container to run the migration scripts.
func RunMigrationContainer ¶ added in v1.0.4
func RunMigrationContainer(dbContainer *SQLContainer, options MigrationOptions) error
RunMigrationContainer creates the migration container and connects to the sql database container to run the migration scripts.
func ToPostgresArgs ¶ added in v1.0.5
func ToPostgresArgs(o SQLOptions) (string, error)
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 SQLOptions) ContainerCallback
func NewPostgreSQLHealthChecker ¶ added in v1.0.5
func NewPostgreSQLHealthChecker(options SQLOptions) ContainerCallback
func NewRedisHealthChecker ¶ added in v1.1.9
func NewRedisHealthChecker(options RedisOptions) ContainerCallback
func NewVaultHealthChecker ¶ added in v1.1.7
func NewVaultHealthChecker(options VaultOptions) 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 // override default entrypoint Entrypoint []string }
MigrationOptions for sql migration container
type MySQLContainer ¶
type MySQLContainer struct {
*SQLContainer
}
func NewMySQLContainer ¶
func NewMySQLContainer(options SQLOptions, containerOptions ...Option) (*MySQLContainer, error)
func SetupMySQL ¶ added in v1.0.4
func SetupMySQL(containerOptions ...Option) (*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 Option ¶
type Option func(*Container)
func DockerRunLink ¶ added in v1.1.1
func Entrypoint ¶ added in v1.1.1
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 ImageTagFromEnv ¶ added in v1.0.8
ImageTagFromEnv loads the image tag from the given environment variable
func Initializer ¶
func Initializer(init ContainerCallback) Option
func RunOptions ¶
type PortBinding ¶ added in v1.0.4
type PostgreSQLContainer ¶ added in v1.0.5
type PostgreSQLContainer struct { *SQLContainer Args string }
func NewPostgreSQLContainer ¶ added in v1.0.5
func NewPostgreSQLContainer(options SQLOptions, containerOptions ...Option) (*PostgreSQLContainer, error)
func SetupPostgreSQL ¶ added in v1.0.5
func SetupPostgreSQL() (*PostgreSQLContainer, error)
setup the postgresql connection if TEST_POSTGRESQL_HOST is defined, then we will use the connection directly. if not, a postgresql container will be started
func (*PostgreSQLContainer) Start ¶ added in v1.0.5
func (container *PostgreSQLContainer) Start() error
func (*PostgreSQLContainer) Teardown ¶ added in v1.0.5
func (container *PostgreSQLContainer) Teardown() error
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 { *Container Options RedisOptions Endpoint string }
func NewRedisContainer ¶
func NewRedisContainer(options RedisOptions, containerOptions ...Option) *RedisContainer
func SetupRedis ¶ added in v1.1.9
func SetupRedis() (*RedisContainer, error)
func (*RedisContainer) Start ¶
func (c *RedisContainer) Start() error
func (*RedisContainer) Teardown ¶ added in v1.1.9
func (c *RedisContainer) Teardown() error
type RedisOptions ¶ added in v1.1.9
func LoadRedisOptions ¶ added in v1.1.9
func LoadRedisOptions() RedisOptions
RedisOptions returns the redis options that will be used for the test cases to connect to.
func (RedisOptions) Endpoint ¶ added in v1.1.9
func (o RedisOptions) Endpoint() string
func (*RedisOptions) UpdateHostFromContainer ¶ added in v1.1.9
func (o *RedisOptions) UpdateHostFromContainer(c *Container) error
UpdateHostFromContainer updates the redis 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_REDIS_HOST can be overridden.
type SQLContainer ¶ added in v1.0.5
type SQLContainer struct { *Container Options SQLOptions URL string }
type SQLOptions ¶ added in v1.0.5
type SQLOptions struct { Driver string // 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() SQLOptions
LoadMySQLOptions returns the mysql options that will be used for the test cases to connect to.
func LoadPostgreSQLOptions ¶ added in v1.0.5
func LoadPostgreSQLOptions() SQLOptions
LoadPostgreSQLOptions returns the postgresql options that will be used for the test cases to connect to.
func (*SQLOptions) ToConnectionString ¶ added in v1.0.5
func (o *SQLOptions) ToConnectionString() (string, error)
func (*SQLOptions) UpdateHostFromContainer ¶ added in v1.0.5
func (o *SQLOptions) 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 VaultContainer ¶ added in v1.1.7
type VaultContainer struct { *Container Options VaultOptions Endpoint string }
func NewVaultContainer ¶ added in v1.1.7
func NewVaultContainer(options VaultOptions, containerOptions ...Option) (*VaultContainer, error)
func SetupVault ¶ added in v1.1.7
func SetupVault() (*VaultContainer, error)
func (*VaultContainer) Start ¶ added in v1.1.7
func (c *VaultContainer) Start() error
func (*VaultContainer) Teardown ¶ added in v1.1.7
func (c *VaultContainer) Teardown() error
type VaultOptions ¶ added in v1.1.7
func LoadVaultOptions ¶ added in v1.1.7
func LoadVaultOptions() VaultOptions
LoadVaultOptions returns the vault options that will be used for the test cases to connect to.
func (VaultOptions) Endpoint ¶ added in v1.1.7
func (o VaultOptions) Endpoint() string
func (*VaultOptions) UpdateHostFromContainer ¶ added in v1.1.7
func (o *VaultOptions) UpdateHostFromContainer(c *Container) error
UpdateHostFromContainer updates the vault 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_VAULT_HOST can be overridden.