Documentation ¶
Overview ¶
Package docker is a collection of utilities to operate Docker objects in Go code tests in a simplified manner.
Index ¶
- func CreateContainer(ctx context.Context, image string, options *Options) (string, error)
- func CreateStartContainer(ctx context.Context, image string, options *Options) (string, error)
- func ExecCommand(ctx context.Context, id string, command string, buffer *bytes.Buffer) error
- func PullImage(ctx context.Context, name string) error
- func RemoveContainer(ctx context.Context, id string) error
- func StartContainer(ctx context.Context, id string) error
- func StopContainer(ctx context.Context, id string) error
- func StopRemoveContainer(ctx context.Context, id string) error
- type Container
- type Database
- type DatabaseContainer
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateContainer ¶
CreateContainer creates a new Docker container and returns its id.
func CreateStartContainer ¶
CreateStartContainer creates a new Docker container and starts it. Returns created container id.
func ExecCommand ¶ added in v0.3.0
ExecCommand executes given shell command in Docker container.
func RemoveContainer ¶
RemoveContainer removes Docker container.
func StartContainer ¶
StartContainer starts Docker container.
func StopContainer ¶
StopContainer stops Docker container.
Types ¶
type Container ¶
type Container interface { Create(ctx context.Context) error Start(ctx context.Context) error CreateStart(ctx context.Context) error Stop(ctx context.Context) error Remove(ctx context.Context) error StopRemove(ctx context.Context) error HasStarted(ctx context.Context) (bool, error) Exec(ctx context.Context, command string, buffer *bytes.Buffer) error }
Container defines container methods.
func NewContainer ¶
NewContainer creates a new Container object.
type DatabaseContainer ¶ added in v0.3.0
DatabaseContainer extends Container interface with database interaction methods.
func NewDatabaseContainer ¶ added in v0.3.0
func NewDatabaseContainer(image string, db Database) DatabaseContainer
NewDatabaseContainer creates a new DatabaseContainer object.
func NewDatabaseContainerWithOptions ¶ added in v0.3.0
func NewDatabaseContainerWithOptions(image string, db Database, options Options) DatabaseContainer
NewDatabaseContainerWithOptions creates a new DatabaseContainer object with optional attributes values specified.