Documentation
¶
Index ¶
Constants ¶
const DefaultNetwork = "acceptance-testing"
Variables ¶
This section is empty.
Functions ¶
func SetEnv ¶
func SetEnv(t *testing.T, matchers ...ConfigPathMatcher)
SetEnv loads the configuration from a file, choosing the proper one depending on the provided matchers. Every matcher returning true as second value will be executed. Matchers are executed in their provided order
Types ¶
type Aceptadora ¶
type Aceptadora struct {
// contains filtered or unexported fields
}
func New ¶
func New(t *testing.T, imagePuller ImagePuller, cfg Config) *Aceptadora
New creates a new Aceptadora. It will try to load the YAML config from the path provided by Config If something goes wrong, it will use testing.T to fail.
func (*Aceptadora) PullImages ¶
func (a *Aceptadora) PullImages(ctx context.Context)
PullImages pulls all the images mentioned in aceptadora.yml This allows doing this outside of the context of the test, and avoid unrelated flaky timeouts in the tests happening when most of the context has been consumed by pulling the image
func (*Aceptadora) Run ¶
func (a *Aceptadora) Run(ctx context.Context, name string)
Run will start a given service (from aceptadora.yml) and register it for stopping later
func (*Aceptadora) Stop ¶
func (a *Aceptadora) Stop(ctx context.Context, name string)
Stop will try to stop the service with the name provided It will fail fatally if such service isn't defined It will skip the service if it's already stopped, and set it to nil once stopped, making this call idempotent Stop is not thread safe.
func (*Aceptadora) StopAll ¶
func (a *Aceptadora) StopAll(ctx context.Context)
StopAll will stop all the services in the reverse order If you need to explicitly stop some service in first place, use Stop() previously.
type Config ¶
type Config struct { YAMLDir string `default:"./"` YAMLName string `default:"aceptadora.yml"` // StopTimeout will be used to stop containers gracefully. // If zero (default), then containers will be forced to stop immediately saving some tear down time. StopTimeout time.Duration `default:"0s"` }
Config is intended to be loaded by "github.com/colega/envconfig"
type ConfigPathMatcher ¶
func EnvConfigAlways ¶
func EnvConfigAlways(path string) ConfigPathMatcher
EnvConfigAlways is a matcher for SetEnv that is always true, useful to load the common acceptance.env config once the env-specifics are loaded.
func EnvConfigWhenEnvVarPresent ¶
func EnvConfigWhenEnvVarPresent(path, envVarName string) ConfigPathMatcher
EnvConfigWhenEnvVarPresent is a matcher for SetEnv that matches when the provided env var name is present
func OneOfEnvConfigs ¶
func OneOfEnvConfigs(matchers ...ConfigPathMatcher) ConfigPathMatcher
OneOfEnvConfigs provides a matcher that returns as the result the result of the first matching matcher. Useful when several matchers would match, like for instance a Github Actions environment is being a Linux at the same time.
type ImagePuller ¶
type ImagePullerConfig ¶
type ImagePullerConfig struct {
Repo []RepositoryConfig
}
ImagePullerConfig configures the pulling options for different image repositories
type ImagePullerImpl ¶
type ImagePullerImpl struct {
// contains filtered or unexported fields
}
func NewImagePuller ¶
func NewImagePuller(t *testing.T, cfg ImagePullerConfig) *ImagePullerImpl
type RepositoryConfig ¶
type RepositoryConfig struct { // Domain is used to specify which domain this config applies to, like `docker.io` Domain string // SkipPulling can be specified if images from this domain are not intended to be pulled // Useful for images previously built locally, or for local testing when repository credentials are not passed to the test SkipPulling bool // Auth provides the default docker library's field to authenticate and will be used for pulling. // Usually Username & Password fields should be filled. Auth registry.AuthConfig }
RepositoryConfig provides the details of access to a docker repository.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
type Service ¶
type Service struct { Image string `yaml:"image"` Network string `yaml:"network"` Binds []string `yaml:"binds"` Command []string `yaml:"command"` EnvFile []string `yaml:"env_file"` Ports []string `yaml:"ports"` IgnoreLogs bool `yaml:"ignore_logs"` }
Service describes a service aceptadora can run