Documentation ¶
Index ¶
- Constants
- func Abs(t *testing.T, path string) string
- func CheckContains(t *testing.T, expected, actual string)
- func CheckDeepEqual(t *testing.T, expected, actual interface{}, opts ...cmp.Option)
- func CheckElementsMatch(t *testing.T, expected, actual interface{})
- func CheckError(t *testing.T, shouldErr bool, err error)
- func CheckErrorAndDeepEqual(t *testing.T, shouldErr bool, err error, expected, actual interface{}, ...)
- func CheckErrorAndExitCode(t *testing.T, expectedCode int, err error)
- func CheckErrorAndFailNow(t *testing.T, shouldErr bool, err error)
- func CheckFileExistAndContent(t *testing.T, path string, expectedContent []byte)
- func CheckMapsMatch(t *testing.T, expected, actual interface{})
- func CheckNotContains(t *testing.T, excluded, actual string)
- func CreateFakeImageTar(ref string, path string) error
- func EnsureTestPanicked(t *testing.T)
- func ReadRefFromFakeTar(input io.Reader) (string, error)
- func Run(t *testing.T, name string, f func(t *T))
- func ServeFile(t *testing.T, content []byte) string
- func SetupFakeWatcher(w watch.Interface) func(a fake_testing.Action) (handled bool, ret watch.Interface, err error)
- func TempFile(t *testing.T, prefix string, content []byte) string
- func YamlObj(t *testing.T) cmp.Option
- type ContainerState
- type FakeAPIClient
- func (f *FakeAPIClient) Add(tag, imageID string) *FakeAPIClient
- func (f *FakeAPIClient) Close() error
- func (f *FakeAPIClient) DiskUsage(ctx context.Context) (types.DiskUsage, error)
- func (f *FakeAPIClient) DistributionInspect(ctx context.Context, ref, encodedRegistryAuth string) (registry.DistributionInspect, error)
- func (f *FakeAPIClient) ImageBuild(_ context.Context, _ io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error)
- func (f *FakeAPIClient) ImageInspectWithRaw(_ context.Context, refOrID string) (types.ImageInspect, []byte, error)
- func (f *FakeAPIClient) ImageList(ctx context.Context, ops types.ImageListOptions) ([]types.ImageSummary, error)
- func (f *FakeAPIClient) ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error)
- func (f *FakeAPIClient) ImagePull(_ context.Context, ref string, _ types.ImagePullOptions) (io.ReadCloser, error)
- func (f *FakeAPIClient) ImagePush(_ context.Context, ref string, _ types.ImagePushOptions) (io.ReadCloser, error)
- func (f *FakeAPIClient) ImageRemove(_ context.Context, _ string, _ types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
- func (f *FakeAPIClient) ImageTag(_ context.Context, image, ref string) error
- func (f *FakeAPIClient) Info(context.Context) (types.Info, error)
- func (f *FakeAPIClient) Pulled() []string
- func (f *FakeAPIClient) Pushed() map[string]string
- func (f *FakeAPIClient) ServerVersion(ctx context.Context) (types.Version, error)
- type FakeCmd
- func CmdRun(command string) *FakeCmd
- func CmdRunDirOut(command string, dir string, output string) *FakeCmd
- func CmdRunEnv(command string, env []string) *FakeCmd
- func CmdRunErr(command string, err error) *FakeCmd
- func CmdRunInput(command, input string) *FakeCmd
- func CmdRunOut(command string, output string) *FakeCmd
- func CmdRunOutErr(command string, output string, err error) *FakeCmd
- func CmdRunWithOutput(command, output string) *FakeCmd
- func (c *FakeCmd) AndRun(command string) *FakeCmd
- func (c *FakeCmd) AndRunDirOut(command string, dir string, output string) *FakeCmd
- func (c *FakeCmd) AndRunEnv(command string, env []string) *FakeCmd
- func (c *FakeCmd) AndRunErr(command string, err error) *FakeCmd
- func (c *FakeCmd) AndRunInput(command, input string) *FakeCmd
- func (c *FakeCmd) AndRunInputOut(command string, input string, output string) *FakeCmd
- func (c *FakeCmd) AndRunOut(command string, output string) *FakeCmd
- func (c *FakeCmd) AndRunOutErr(command string, output string, err error) *FakeCmd
- func (c *FakeCmd) AndRunWithOutput(command, output string) *FakeCmd
- func (c *FakeCmd) ForTest(t *testing.T)
- func (c *FakeCmd) RunCmd(ctx context.Context, cmd *exec.Cmd) error
- func (c *FakeCmd) RunCmdOut(ctx context.Context, cmd *exec.Cmd) ([]byte, error)
- func (c *FakeCmd) TimesCalled() int
- type FakeFileSystem
- type ForTester
- type T
- func (t *T) Chdir(dir string)
- func (t *T) CheckContains(expected, actual string)
- func (t *T) CheckDeepEqual(expected, actual interface{}, opts ...cmp.Option)
- func (t *T) CheckElementsMatch(expected, actual interface{})
- func (t *T) CheckEmpty(actual interface{})
- func (t *T) CheckError(shouldErr bool, err error)
- func (t *T) CheckErrorAndDeepEqual(shouldErr bool, err error, expected, actual interface{}, opts ...cmp.Option)
- func (t *T) CheckErrorAndExitCode(expectedCode int, err error)
- func (t *T) CheckErrorAndFailNow(shouldErr bool, err error)
- func (t *T) CheckErrorContains(message string, err error)
- func (t *T) CheckFalse(actual bool)
- func (t *T) CheckFileExistAndContent(filePath string, expectedContent []byte)
- func (t *T) CheckMapsMatch(expected, actual interface{})
- func (t *T) CheckMatches(pattern, actual string)
- func (t *T) CheckNil(actual interface{})
- func (t *T) CheckNoError(err error)
- func (t *T) CheckNotNil(actual interface{})
- func (t *T) CheckTrue(actual bool)
- func (t *T) CheckTypeEquality(expected, actual interface{})
- func (t *T) NewTempDir() *TempDir
- func (t *T) Override(dest, tmp interface{})
- func (t *T) RequireNoError(err error)
- func (t *T) RequireNonNilResult(x interface{}, err error) interface{}
- func (t *T) SetArgs(args []string)
- func (t *T) SetEnvs(envs map[string]string)
- func (t *T) SetStdin(content []byte)
- func (t *T) SetupFakeKubernetesContext(config api.Config)
- func (t *T) TempFile(prefix string, content []byte) string
- type TempDir
- func (h *TempDir) Chdir() *TempDir
- func (h *TempDir) Chtimes(file string, t time.Time) *TempDir
- func (h *TempDir) List() ([]string, error)
- func (h *TempDir) Mkdir(dir string) *TempDir
- func (h *TempDir) Path(file string) string
- func (h *TempDir) Paths(files ...string) []string
- func (h *TempDir) Remove(file string) *TempDir
- func (h *TempDir) Rename(oldName, newName string) *TempDir
- func (h *TempDir) Root() string
- func (h *TempDir) Symlink(dst, src string) *TempDir
- func (h *TempDir) Touch(files ...string) *TempDir
- func (h *TempDir) Write(file, content string) *TempDir
- func (h *TempDir) WriteFiles(files map[string]string) *TempDir
Constants ¶
const ( Created ContainerState = 0 Started ContainerState = 1 TestUtilization uint64 = 424242 )
Variables ¶
This section is empty.
Functions ¶
func CheckContains ¶ added in v0.25.0
func CheckDeepEqual ¶ added in v0.14.0
func CheckElementsMatch ¶ added in v1.7.1
CheckElementsMatch validates that two given slices contain the same elements while disregarding their order. Elements of both slices have to be comparable by '=='
func CheckErrorAndDeepEqual ¶
func CheckErrorAndExitCode ¶ added in v1.30.0
func CheckErrorAndFailNow ¶ added in v1.21.0
func CheckFileExistAndContent ¶ added in v1.25.0
func CheckMapsMatch ¶ added in v1.36.0
CheckMapsMatch validates that two given maps contain the same key-value pairs
func CheckNotContains ¶ added in v1.7.1
func CreateFakeImageTar ¶ added in v0.41.0
TODO(dgageot): create something that looks more like an actual tar file.
func EnsureTestPanicked ¶ added in v0.31.0
func ServeFile ¶ added in v0.2.0
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 SetupFakeWatcher ¶ added in v0.33.0
func SetupFakeWatcher(w watch.Interface) func(a fake_testing.Action) (handled bool, ret watch.Interface, err error)
SetupFakeWatcher helps set up a fake Kubernetes watcher
Types ¶
type ContainerState ¶ added in v1.0.0
type ContainerState int
type FakeAPIClient ¶ added in v0.21.0
type FakeAPIClient struct { client.CommonAPIClient ErrImageBuild bool ErrImageInspect bool ErrImagePush bool ErrImagePull bool ErrImageList bool ErrImageRemove bool ErrStream bool ErrVersion bool // will return the "test error" error on first <DUFails> DiskUsage calls DUFails int Built []types.ImageBuildOptions // ref -> [id] LocalImages map[string][]string // contains filtered or unexported fields }
func (*FakeAPIClient) Add ¶ added in v0.35.0
func (f *FakeAPIClient) Add(tag, imageID string) *FakeAPIClient
func (*FakeAPIClient) Close ¶ added in v0.21.0
func (f *FakeAPIClient) Close() error
func (*FakeAPIClient) DistributionInspect ¶ added in v0.40.0
func (f *FakeAPIClient) DistributionInspect(ctx context.Context, ref, encodedRegistryAuth string) (registry.DistributionInspect, error)
func (*FakeAPIClient) ImageBuild ¶ added in v0.21.0
func (f *FakeAPIClient) ImageBuild(_ context.Context, _ io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error)
func (*FakeAPIClient) ImageInspectWithRaw ¶ added in v0.21.0
func (f *FakeAPIClient) ImageInspectWithRaw(_ context.Context, refOrID string) (types.ImageInspect, []byte, error)
func (*FakeAPIClient) ImageList ¶ added in v0.24.0
func (f *FakeAPIClient) ImageList(ctx context.Context, ops types.ImageListOptions) ([]types.ImageSummary, error)
func (*FakeAPIClient) ImageLoad ¶ added in v0.41.0
func (f *FakeAPIClient) ImageLoad(ctx context.Context, input io.Reader, quiet bool) (types.ImageLoadResponse, error)
func (*FakeAPIClient) ImagePull ¶ added in v0.21.1
func (f *FakeAPIClient) ImagePull(_ context.Context, ref string, _ types.ImagePullOptions) (io.ReadCloser, error)
func (*FakeAPIClient) ImagePush ¶ added in v0.21.0
func (f *FakeAPIClient) ImagePush(_ context.Context, ref string, _ types.ImagePushOptions) (io.ReadCloser, error)
func (*FakeAPIClient) ImageRemove ¶ added in v1.7.1
func (f *FakeAPIClient) ImageRemove(_ context.Context, _ string, _ types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
func (*FakeAPIClient) ImageTag ¶ added in v0.21.0
func (f *FakeAPIClient) ImageTag(_ context.Context, image, ref string) error
func (*FakeAPIClient) Pulled ¶ added in v1.7.1
func (f *FakeAPIClient) Pulled() []string
func (*FakeAPIClient) Pushed ¶ added in v0.25.0
func (f *FakeAPIClient) Pushed() map[string]string
func (*FakeAPIClient) ServerVersion ¶ added in v1.7.1
type FakeCmd ¶ added in v0.6.0
type FakeCmd struct {
// contains filtered or unexported fields
}
func CmdRunDirOut ¶ added in v1.31.0
func CmdRunInput ¶ added in v0.38.0
func CmdRunOutErr ¶ added in v0.38.0
func CmdRunWithOutput ¶ added in v1.5.0
CmdRunWithOutput programs the fake runner with a command and expected output
func (*FakeCmd) AndRunDirOut ¶ added in v1.31.0
func (*FakeCmd) AndRunInput ¶ added in v0.38.0
func (*FakeCmd) AndRunInputOut ¶ added in v1.7.1
func (*FakeCmd) AndRunOutErr ¶ added in v0.38.0
func (*FakeCmd) AndRunWithOutput ¶ added in v1.5.0
AndRunWithOutput takes a command and an expected output. It expected to match up with a call to RunCmd, and pipes the provided output to RunCmd's exec.Cmd's stdout.
func (*FakeCmd) TimesCalled ¶ added in v1.18.0
type FakeFileSystem ¶ added in v1.18.0
type T ¶ added in v0.31.0
func (*T) CheckContains ¶ added in v0.31.0
func (*T) CheckDeepEqual ¶ added in v0.31.0
func (*T) CheckElementsMatch ¶ added in v1.28.0
func (t *T) CheckElementsMatch(expected, actual interface{})
CheckElementsMatch validates that two given slices contain the same elements while disregarding their order. Elements of both slices have to be comparable by '=='
func (*T) CheckEmpty ¶ added in v1.1.0
func (t *T) CheckEmpty(actual interface{})
func (*T) CheckError ¶ added in v0.31.0
func (*T) CheckErrorAndDeepEqual ¶ added in v0.31.0
func (*T) CheckErrorAndExitCode ¶ added in v1.30.0
func (*T) CheckErrorAndFailNow ¶ added in v1.21.0
CheckErrorAndFailNow checks that the provided error complies with whether or not we expect an error and fails the test execution immediately if it does not. Useful for testing functions which return (obj interface{}, e error) and subsequent checks operate on `obj` assuming that it is not nil.
func (*T) CheckErrorContains ¶ added in v0.31.0
CheckErrorContains checks that an error is not nil and contains a given message.
func (*T) CheckFalse ¶ added in v1.1.0
func (*T) CheckFileExistAndContent ¶ added in v1.25.0
CheckFileExistAndContent checks if the given file path exists and the content is expected.
func (*T) CheckMapsMatch ¶ added in v1.36.0
func (t *T) CheckMapsMatch(expected, actual interface{})
CheckMapsMatch validates that two given maps contain the same key value pairs.
func (*T) CheckMatches ¶ added in v0.37.0
func (*T) CheckNoError ¶ added in v0.31.0
func (*T) CheckNotNil ¶ added in v1.1.0
func (t *T) CheckNotNil(actual interface{})
func (*T) CheckTypeEquality ¶ added in v1.7.1
func (t *T) CheckTypeEquality(expected, actual interface{})
func (*T) NewTempDir ¶ added in v0.31.0
func (*T) RequireNoError ¶ added in v0.40.0
func (*T) RequireNonNilResult ¶ added in v1.7.1
func (*T) SetEnvs ¶ added in v0.31.0
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 (*T) SetupFakeKubernetesContext ¶ added in v0.31.0
SetupFakeKubernetesContext replaces the current Kubernetes configuration file to setup a fixed current context.
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
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
Chtimes changes the times for a file in the temp directory.
func (*TempDir) Paths ¶ added in v0.26.0
Paths returns the paths to a list of files in the temp directory.