dockerutil

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	S3DefaultAccessKey = "access_key"
	S3DefaultSecretKey = "secret_key"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*DockerClient
}

Client wraps the go-dockerclient Client type to add some convenience methods.

It embeds that type so all properties and methods are supported.

type Container

type Container struct {
	*DockerContainer
	// contains filtered or unexported fields
}

Container wraps the go-dockerclient Container type to add some convenience methods.

It embeds that type so all properties and methods are supported.

type DockerClient

type DockerClient = docker.Client

type DockerContainer

type DockerContainer = docker.Container

type S3Object

type S3Object struct {
	Path string
	Size int64
}

type S3Suite

type S3Suite struct {
	Suite

	// S3 is the AWS SDK client, which will be assigned when
	// SetupSuite() completes successfully.
	S3        *s3.S3
	AccessKey string
	SecretKey string
	Config    *aws.Config
}

S3Suite is a base test suite type which launches a local Amazon S3-compatible docker container and configures the Amazon AWS SDK's S3 client to point to it.

It also provides a number of wrapper functions for S3 SDK calls that simplify manipulating and inspecting S3 for test case setup and teardown. Rather than returning errors, these functions will cause test errors or failures, to keep the test code minimal.

func (*S3Suite) CreateBucket

func (s *S3Suite) CreateBucket(name string)

func (*S3Suite) DeleteAllObjects

func (s *S3Suite) DeleteAllObjects(bucket string)

func (*S3Suite) DeleteBucket

func (s *S3Suite) DeleteBucket(name string)

func (*S3Suite) DeleteObject

func (s *S3Suite) DeleteObject(bucket, path string)

func (*S3Suite) DeleteObjects

func (s *S3Suite) DeleteObjects(bucket string, paths []string)

func (*S3Suite) GetObject

func (s *S3Suite) GetObject(bucket, path string) []byte

func (*S3Suite) GetObjectWithResponse

func (s *S3Suite) GetObjectWithResponse(bucket, path string) (resp *s3.GetObjectOutput, respData []byte)

func (*S3Suite) GetObjects

func (s *S3Suite) GetObjects(bucket string, paths []string) map[string][]byte

func (*S3Suite) ListObjects

func (s *S3Suite) ListObjects(bucket, prefix string) []S3Object

func (*S3Suite) PutObject

func (s *S3Suite) PutObject(bucket, path, contentType string, data []byte)

func (*S3Suite) PutObjects

func (s *S3Suite) PutObjects(bucket, contentType string, objs map[string][]byte)

func (*S3Suite) SetupSuite

func (s *S3Suite) SetupSuite()

type Suite

type Suite struct {
	suite.Suite

	// Container is a pointer to the Container structure, which will
	// be assigned after SetupSuite() successfully starts the
	// container.
	Container *Container

	// Start is a function which launches a container, returning the
	// container and an optional error. Each concrete docker test
	// suite must set the Start member before propagating the
	// SetupSuite() call, and should call one of the container
	// starting functions provided by dockerutil.
	//
	// See S3Suite for a concrete example.
	Start func() (*Container, error)
}

Suite provides a base type to use for constructing test suites that depend on docker container. Concrete test suite types must set the Start function.

Jump to

Keyboard shortcuts

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