testutil

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2019 License: Apache-2.0 Imports: 24 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chdir added in v0.23.0

func Chdir(t *testing.T, dir string) func()

Chdir changes current directory for a test

func CheckContains added in v0.25.0

func CheckContains(t *testing.T, expected, actual string)

func CheckDeepEqual added in v0.14.0

func CheckDeepEqual(t *testing.T, expected, actual interface{}, opts ...cmp.Option)

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{}, opts ...cmp.Option)

func CheckErrorContains added in v0.28.0

func CheckErrorContains(t *testing.T, message string, err error)

CheckErrorContains checks that an error is not nil and contains a given message.

func EnsureTestPanicked added in v0.31.0

func EnsureTestPanicked(t *testing.T)

func Override added in v0.30.0

func Override(t *testing.T, dest, tmp interface{}) func()

Override sets a dest variable to a given value. Returns the function to call to restore the variable to its original state.

func Run added in v0.31.0

func Run(t *testing.T, name string, f func(t *T))

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()

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 FakeAPIClient added in v0.21.0

type FakeAPIClient struct {
	client.CommonAPIClient

	TagToImageID    map[string]string
	ImageSummaries  []types.ImageSummary
	RepoDigests     []string
	ErrImageBuild   bool
	ErrImageInspect bool
	ErrImageTag     bool
	ErrImagePush    bool
	ErrImagePull    bool
	ErrStream       bool

	Pushed       []string
	PushedImages []string
	// contains filtered or unexported fields
}

func (*FakeAPIClient) Close added in v0.21.0

func (f *FakeAPIClient) Close() error

func (*FakeAPIClient) ImageBuild added in v0.21.0

func (*FakeAPIClient) ImageInspectWithRaw added in v0.21.0

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

func (*FakeAPIClient) ImageList added in v0.24.0

func (f *FakeAPIClient) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error)

func (*FakeAPIClient) ImagePull added in v0.21.1

func (*FakeAPIClient) ImagePush added in v0.21.0

func (*FakeAPIClient) ImageTag added in v0.21.0

func (f *FakeAPIClient) ImageTag(_ context.Context, image, ref string) error

func (*FakeAPIClient) Info added in v0.21.0

type FakeCmd added in v0.6.0

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

func FakeRun added in v0.31.0

func FakeRun(t *testing.T, command string) *FakeCmd

func FakeRunErr added in v0.31.0

func FakeRunErr(t *testing.T, command string, err error) *FakeCmd

func FakeRunInput added in v0.31.0

func FakeRunInput(t *testing.T, command, input string) *FakeCmd

func FakeRunOut added in v0.31.0

func FakeRunOut(t *testing.T, command string, output string) *FakeCmd

func FakeRunOutErr added in v0.31.0

func FakeRunOutErr(t *testing.T, command string, output string, err error) *FakeCmd

func NewFakeCmd added in v0.6.0

func NewFakeCmd(t *testing.T) *FakeCmd

func (*FakeCmd) RunCmd added in v0.6.0

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

func (*FakeCmd) RunCmdOut added in v0.6.0

func (c *FakeCmd) RunCmdOut(cmd *exec.Cmd) ([]byte, error)

func (*FakeCmd) WithRun added in v0.21.0

func (c *FakeCmd) WithRun(command string) *FakeCmd

func (*FakeCmd) WithRunErr added in v0.21.0

func (c *FakeCmd) WithRunErr(command string, err error) *FakeCmd

func (*FakeCmd) WithRunInput added in v0.21.0

func (c *FakeCmd) WithRunInput(command, input string) *FakeCmd

func (*FakeCmd) WithRunOut added in v0.21.0

func (c *FakeCmd) WithRunOut(command string, output string) *FakeCmd

func (*FakeCmd) WithRunOutErr added in v0.21.0

func (c *FakeCmd) WithRunOutErr(command string, output string, err error) *FakeCmd

type T added in v0.31.0

type T struct {
	*testing.T
	// contains filtered or unexported fields
}

func (*T) Chdir added in v0.31.0

func (t *T) Chdir(dir string)

func (*T) CheckContains added in v0.31.0

func (t *T) CheckContains(expected, actual string)

func (*T) CheckDeepEqual added in v0.31.0

func (t *T) CheckDeepEqual(expected, actual interface{}, opts ...cmp.Option)

func (*T) CheckError added in v0.31.0

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

func (*T) CheckErrorAndDeepEqual added in v0.31.0

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

func (*T) CheckErrorAndTypeEquality added in v0.31.0

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

func (*T) CheckErrorContains added in v0.31.0

func (t *T) CheckErrorContains(message string, err error)

func (*T) CheckNoError added in v0.31.0

func (t *T) CheckNoError(err error)

func (*T) FakeRunOut added in v0.31.0

func (t *T) FakeRunOut(command string, output string) *FakeCmd

func (*T) FakeRunOutErr added in v0.31.0

func (t *T) FakeRunOutErr(command string, output string, err error) *FakeCmd

func (*T) NewTempDir added in v0.31.0

func (t *T) NewTempDir() *TempDir

func (*T) Override added in v0.31.0

func (t *T) Override(dest, tmp interface{})

func (*T) SetEnvs added in v0.31.0

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

func (*T) SetupFakeKubernetesContext added in v0.31.0

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

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

func (*T) TempFile added in v0.31.0

func (t *T) TempFile(prefix string, content []byte) string

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) Paths added in v0.26.0

func (h *TempDir) Paths(files ...string) []string

Paths returns the paths to a list of files 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) Rename added in v0.25.0

func (h *TempDir) Rename(oldName, newName string) *TempDir

Rename renames a file from oldname to newname

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