helpers

package
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BuildCommand is the command to build or rebuild services
	BuildCommand = "build"
	// DownCommand is the command to stop and remove containers and networks
	DownCommand = "down"
	// ExecCommand is the command to execute a command in a running container.
	ExecCommand = "exec"
	// KillCommand is the command to force stop service containers.
	KillCommand = "kill"
	// LogsCommand is the command to view output from containers
	LogsCommand = "logs"
	// RestartCommand is the command to restart service containers
	RestartCommand = "restart"
	// RmCommand is the command to removes stopped service containers
	RmCommand = "rm"
	// RunCommand is the command to run a one-off command on a service.
	RunCommand = "run"
	// StartCommand is the command to start services
	StartCommand = "start"
	// StopCommand is the command to stop services
	StopCommand = "stop"
	// UpCommand is the command to create and start containers
	UpCommand = "up"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AssertAndCommander

type AssertAndCommander interface {
	Commander
	AssertExectedResult(expected, result string)
}

type CommandFactorier

type CommandFactorier interface {
	Command(command string) *DockerComposeTerratestCommand
}

type Commander

type Commander interface {
	Execute() (string, error)
}

type DockerComposeStack

type DockerComposeStack struct {
	DownCommand     Commander
	PostDownCommand []Commander
	PostUpCommand   []Commander
	PreDownCommand  []Commander
	PreUpCommand    []Commander
	UpCommand       Commander
}

DockerComposeStack is a struct that defines the docker compose stack where the test will be executed

func NewDockerComposeStack

func NewDockerComposeStack(opts ...DockerComposeStackOptionsFunc) *DockerComposeStack

NewDockerComposeStack creates a new DockerComposeStack

func (*DockerComposeStack) Down

func (s *DockerComposeStack) Down() error

Down stops and removes the stack where the tests were executed

func (*DockerComposeStack) DownAndUp

func (s *DockerComposeStack) DownAndUp() error

DownAndUp cleans up the stack and creates and starts it again

func (*DockerComposeStack) Execute

func (c *DockerComposeStack) Execute(cmd Commander) error

Execute executes a command in the stack

func (*DockerComposeStack) ExecuteAndCompare

func (c *DockerComposeStack) ExecuteAndCompare(cmd AssertAndCommander, expectedResult string) error

ExecuteAndCompare executes a command in the stack and compares the result with the expected result

func (*DockerComposeStack) Options

Options sets options for the DockerComposeStack

func (*DockerComposeStack) Up

func (s *DockerComposeStack) Up() error

Up creates and starts the stack where the tests will be executed

type DockerComposeStackOptionsFunc

type DockerComposeStackOptionsFunc func(*DockerComposeStack)

DockerComposeStackOptionsFunc is a function used to configure the service

func WithDownCommand

func WithDownCommand(cmd Commander) DockerComposeStackOptionsFunc

WithDownCommand sets the down command for the DockerComposeStack

func WithStackPostDownCommand

func WithStackPostDownCommand(cmd ...Commander) DockerComposeStackOptionsFunc

WithStackPostDownCommand sets the post-down commands for the DockerComposeStack

func WithStackPostUpCommand

func WithStackPostUpCommand(cmd ...Commander) DockerComposeStackOptionsFunc

WithStackPostUpCommand sets the post-up commands for the DockerComposeStack

func WithStackPreDownCommand

func WithStackPreDownCommand(cmd ...Commander) DockerComposeStackOptionsFunc

WithStackPreDownCommand sets the pre-down commands for the DockerComposeStack

func WithStackPreUpCommand

func WithStackPreUpCommand(cmd ...Commander) DockerComposeStackOptionsFunc

WithStackPreUpCommand sets the pre-up commands for the DockerComposeStack

func WithUpCommand

func WithUpCommand(cmd Commander) DockerComposeStackOptionsFunc

WithUpCommand sets the up command for the DockerComposeStack

type DockerComposeTerratestCommand

type DockerComposeTerratestCommand struct {
	// contains filtered or unexported fields
}

DockerComposeTerratestCommand that defines a Terratest docker-compose command

func NewDockerComposeTerratestCommand

func NewDockerComposeTerratestCommand(t *testing.T, options *docker.Options) *DockerComposeTerratestCommand

NewDockerComposeTerratestCommand creates a new DockerComposeTerratestCommand

func (*DockerComposeTerratestCommand) AssertExectedResult

func (c *DockerComposeTerratestCommand) AssertExectedResult(expected, result string)

func (*DockerComposeTerratestCommand) Execute

func (c *DockerComposeTerratestCommand) Execute() (string, error)

Execute runs the DockerComposeTerratestCommand

func (*DockerComposeTerratestCommand) WithCommand

WithCommand sets the command for the DockerComposeTerratestCommand

func (*DockerComposeTerratestCommand) WithCommandArgs

WithCommandArgs sets the command arguments for the DockerComposeTerratestCommand

func (*DockerComposeTerratestCommand) WithVerbose

WithVerbose sets the verbose flag for the DockerComposeTerratestCommand

type DockerComposeTerratestCommandFactory

type DockerComposeTerratestCommandFactory struct {
	// contains filtered or unexported fields
}

DockerComposeTerratestCommandFactory that defines a Terratest docker-compose command factory

func NewDockerComposeTerratestCommandFactory

func NewDockerComposeTerratestCommandFactory(t *testing.T, options *docker.Options) *DockerComposeTerratestCommandFactory

NewDockerComposeTerratestCommandFactory creates a new DockerComposeTerratestCommandFactory

func (*DockerComposeTerratestCommandFactory) Command

Command creates a new DockerComposeTerratestCommand for the command cmd

type FunctionalTestsSuite

type FunctionalTestsSuite struct {
	suite.Suite
	CommandFactory   CommandFactorier
	SetupSuiteFunc   func() error
	Stack            *DockerComposeStack
	TearDownSuitFunc func() error
}

FunctionalTestsSuite is a struct that defines the functional test suite

func NewFunctionalTestsSuite

func NewFunctionalTestsSuite(opts ...OptionsFunc) *FunctionalTestsSuite

NewFunctionalTestsSuite creates a new FunctionalTestsSuite

func (*FunctionalTestsSuite) Options

func (suite *FunctionalTestsSuite) Options(opts ...OptionsFunc)

Options sets options for the FunctionalTestsSuite

func (*FunctionalTestsSuite) SetupSuite

func (suite *FunctionalTestsSuite) SetupSuite()

SetupSuite runs before the tests and setups the test suite

func (*FunctionalTestsSuite) TearDownSuite

func (suite *FunctionalTestsSuite) TearDownSuite()

TearDownSuite runs after the tests and tears down the test suite

type OptionsFunc

type OptionsFunc func(*FunctionalTestsSuite)

OptionsFunc is a function used to configure the FunctionalTestsSuite

func WithCommandFactory

func WithCommandFactory(factory CommandFactorier) OptionsFunc

WithCommandFactory sets the command factory for the FunctionalTestsSuite

func WithSetupSuiteFunc

func WithSetupSuiteFunc(f func() error) OptionsFunc

WithSetupSuiteFunc sets the setup suite function for the FunctionalTestsSuite

func WithStack

func WithStack(stack *DockerComposeStack) OptionsFunc

WithStack sets the stack for the FunctionalTestsSuite

func WithTearDownSuiteFunc

func WithTearDownSuiteFunc(f func() error) OptionsFunc

WithTearDownSuiteFunc sets the tear down suite function for the FunctionalTestsSuite

type QuiteLogger

type QuiteLogger struct{}

func (*QuiteLogger) Logf

func (l *QuiteLogger) Logf(t testing.TestingT, format string, args ...interface{})

type RetryCommand

type RetryCommand struct {
	// contains filtered or unexported fields
}

func NewRetryCommand

func NewRetryCommand(commander Commander) *RetryCommand

func (*RetryCommand) Execute

func (r *RetryCommand) Execute() (string, error)

func (*RetryCommand) WithPostRetryCommand

func (r *RetryCommand) WithPostRetryCommand(cmd ...Commander) *RetryCommand

func (*RetryCommand) WithRetry

func (r *RetryCommand) WithRetry(retry int) *RetryCommand

func (*RetryCommand) WithWaitTimeTillNextRetrySeconds

func (r *RetryCommand) WithWaitTimeTillNextRetrySeconds(waitTimeTillNextRetrySeconds int) *RetryCommand

Jump to

Keyboard shortcuts

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