testutil

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckError

func CheckError(t *testing.T, shouldErr bool, err error)

func CheckErrorAndDeepEqual

func CheckErrorAndDeepEqual(t *testing.T, shouldErr bool, err error, expected, actual interface{})

func CheckErrorAndTypeEquality

func CheckErrorAndTypeEquality(t *testing.T, shouldErr bool, err error, expected, actual interface{})

func NewFakeImageAPIClientCloser

func NewFakeImageAPIClientCloser() (client.ImageAPIClient, io.Closer, error)

func NewFakeImageAPIClientCloserBuildError

func NewFakeImageAPIClientCloserBuildError() (client.ImageAPIClient, io.Closer, error)

func NewFakeImageAPIClientCloserListError

func NewFakeImageAPIClientCloserListError() (client.ImageAPIClient, io.Closer, error)

func NewFakeImageAPIClientCloserTagError

func NewFakeImageAPIClientCloserTagError() (client.ImageAPIClient, io.Closer, error)

func ServeFile added in v0.2.0

func ServeFile(t *testing.T, content []byte) (url string, tearDown func())

ServeFile serves a file with http. Returns the url to the file and a teardown function that should be called to properly stop the server.

func SetEnvs

func SetEnvs(t *testing.T, envs map[string]string) func(*testing.T)

SetEnvs takes a map of key values to set using os.Setenv and returns a function that can be called to reset the envs to their previous values.

func TempFile added in v0.2.0

func TempFile(t *testing.T, prefix string, content []byte) (name string, tearDown func())

TempFile creates a temporary file with a given content. Returns the file name and a teardown function that should be called to properly delete the file.

Types

type BadReader

type BadReader struct{}

func (BadReader) Read

func (BadReader) Read([]byte) (int, error)

type BadWriter

type BadWriter struct{}

func (BadWriter) Write

func (BadWriter) Write([]byte) (int, error)

type FakeImageAPIClient

type FakeImageAPIClient struct {
	*client.Client
	// contains filtered or unexported fields
}

func NewFakeImageAPIClient

func NewFakeImageAPIClient(initContents map[string]string, opts *FakeImageAPIOptions) *FakeImageAPIClient

func (*FakeImageAPIClient) Close

func (f *FakeImageAPIClient) Close() error

func (*FakeImageAPIClient) ImageBuild

func (*FakeImageAPIClient) ImageList

func (*FakeImageAPIClient) ImagePush

func (*FakeImageAPIClient) ImageTag

func (f *FakeImageAPIClient) ImageTag(ctx context.Context, image, ref string) error

type FakeImageAPIOptions

type FakeImageAPIOptions struct {
	ErrImageBuild     bool
	ErrImageList      bool
	ErrImageListEmpty bool
	ErrImageTag       bool
	ErrImagePush      bool

	BuildImageID string

	ReturnBody io.ReadCloser
}

type FakeReaderCloser

type FakeReaderCloser struct {
	Err error
}

func (FakeReaderCloser) Close

func (f FakeReaderCloser) Close() error

func (FakeReaderCloser) Read

func (f FakeReaderCloser) Read([]byte) (int, error)

type FakeRunCommand

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

func NewFakeRunCommand

func NewFakeRunCommand(stdout, stderr string, err error) *FakeRunCommand

func (*FakeRunCommand) RunCommand

func (f *FakeRunCommand) RunCommand(*exec.Cmd, io.Reader) ([]byte, []byte, error)

type MultiFakeRunCommand

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

func NewMultiFakeRunCommand

func NewMultiFakeRunCommand(r map[string]*FakeRunCommand) *MultiFakeRunCommand

func (*MultiFakeRunCommand) RunCommand

func (f *MultiFakeRunCommand) RunCommand(c *exec.Cmd, stdin io.Reader) ([]byte, []byte, error)

Jump to

Keyboard shortcuts

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