testutil

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2018 License: Apache-2.0 Imports: 21 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 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 SetupFakeKubernetesContext added in v0.9.0

func SetupFakeKubernetesContext(t *testing.T, config api.Config) func()

SetupFakeKubernetesContext replaces the current kubernetes configuration file to setup a fixed current context.

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 FakeCmd added in v0.6.0

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

func NewFakeCmd added in v0.6.0

func NewFakeCmd(expectedCommand string, err error) *FakeCmd

func NewFakeCmdOut added in v0.6.0

func NewFakeCmdOut(expectedCommand, stdout string, err error) *FakeCmd

func (*FakeCmd) RunCmd added in v0.6.0

func (f *FakeCmd) RunCmd(cmd *exec.Cmd) error

func (*FakeCmd) RunCmdOut added in v0.6.0

func (f *FakeCmd) RunCmdOut(cmd *exec.Cmd) ([]byte, 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) ImageInspectWithRaw added in v0.11.0

func (f *FakeImageAPIClient) ImageInspectWithRaw(ctx context.Context, ref string) (types.ImageInspect, []byte, error)

func (*FakeImageAPIClient) ImagePush

func (*FakeImageAPIClient) ImageTag

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

func (*FakeImageAPIClient) Info added in v0.3.0

type FakeImageAPIOptions

type FakeImageAPIOptions struct {
	ErrImageBuild   bool
	ErrImageInspect 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 TempDir added in v0.3.0

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

TempDir offers actions on a temp directory.

func NewTempDir added in v0.12.0

func NewTempDir(t *testing.T) (tmp *TempDir, tearDown func())

NewTempDir creates a temporary directory and a teardown function that should be called to properly delete the directory content.

func (*TempDir) Chtimes added in v0.12.0

func (h *TempDir) Chtimes(file string, t time.Time) *TempDir

Chtimes changes the times for a file in the temp directory.

func (*TempDir) List added in v0.12.0

func (h *TempDir) List() ([]string, error)

List lists all the files in the temp directory.

func (*TempDir) Mkdir added in v0.12.0

func (h *TempDir) Mkdir(dir string) *TempDir

Mkdir makes a sub-directory in the temp directory.

func (*TempDir) Path added in v0.12.0

func (h *TempDir) Path(file string) string

Path returns the path to a file in the temp directory.

func (*TempDir) Remove added in v0.12.0

func (h *TempDir) Remove(file string) *TempDir

Remove deletes a file from the temp directory.

func (*TempDir) Root added in v0.12.0

func (h *TempDir) Root() string

Root returns the temp directory.

func (*TempDir) Write added in v0.12.0

func (h *TempDir) Write(file, content string) *TempDir

Write write content to a file in the temp directory.

Jump to

Keyboard shortcuts

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