testutil

package
v0.0.0-...-15868fb Latest Latest
Warning

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

Go to latest
Published: May 1, 2019 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chdir

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

Chdir changes current directory for a test

func CheckContains

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

func CheckDeepEqual

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 CheckErrorAndTypeEquality

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

func CheckErrorContains

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

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

func CreateTempFileWithContents

func CreateTempFileWithContents(t *testing.T, dir string, name string, content []byte) string

CreateTempFileWithContents creates a temporary file in the dir specified or os.TempDir by default with contents mentioned.

func ServeFile

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

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

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

func TempFile

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

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

func (f *FakeAPIClient) Close() error

func (*FakeAPIClient) ImageBuild

func (*FakeAPIClient) ImageInspectWithRaw

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

func (*FakeAPIClient) ImageList

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

func (*FakeAPIClient) ImagePull

func (*FakeAPIClient) ImagePush

func (*FakeAPIClient) ImageTag

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

func (*FakeAPIClient) Info

type FakeCmd

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

func NewFakeCmd

func NewFakeCmd(t *testing.T) *FakeCmd

func (*FakeCmd) RunCmd

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

func (*FakeCmd) RunCmdOut

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

func (*FakeCmd) WithRun

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

func (*FakeCmd) WithRunErr

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

func (*FakeCmd) WithRunInput

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

func (*FakeCmd) WithRunOut

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

func (*FakeCmd) WithRunOutErr

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

type TempDir

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

TempDir offers actions on a temp directory.

func NewTempDir

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

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

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

func (*TempDir) List

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

List lists all the files in the temp directory.

func (*TempDir) Mkdir

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

Mkdir makes a sub-directory in the temp directory.

func (*TempDir) Path

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

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

func (*TempDir) Paths

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

Paths returns the paths to a list of files in the temp directory.

func (*TempDir) Remove

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

Remove deletes a file from the temp directory.

func (*TempDir) Rename

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

Rename renames a file from oldname to newname

func (*TempDir) Root

func (h *TempDir) Root() string

Root returns the temp directory.

func (*TempDir) Write

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