testhelpers

package
v0.19.3 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllLogs added in v0.11.0

func AllLogs(logHandler *memory.Handler) string

func AssertContains

func AssertContains(t *testing.T, slice []string, elements ...string)

func AssertDoesNotContain added in v0.16.0

func AssertDoesNotContain(t *testing.T, slice []string, element string)

func AssertEq

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

Assert deep equality (and provide useful difference as a test failure)

func AssertError

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

func AssertJSONEq

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

func AssertLogEntry added in v0.14.1

func AssertLogEntry(t *testing.T, logHandler *memory.Handler, expected string)

func AssertMatch

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

func AssertNil

func AssertNil(t *testing.T, actual interface{})

func AssertNoLogEntry added in v0.14.1

func AssertNoLogEntry(t *testing.T, logHandler *memory.Handler, expected string)

func AssertNotNil added in v0.9.0

func AssertNotNil(t *testing.T, actual interface{})

func AssertPathDoesNotExist

func AssertPathDoesNotExist(t *testing.T, path string)

func AssertPathExists

func AssertPathExists(t *testing.T, path string)

func AssertSameInstance

func AssertSameInstance(t *testing.T, actual, expected interface{})

Assert the simplistic pointer (or literal value) equality

func AssertStringContains

func AssertStringContains(t *testing.T, str string, expected string)

func AssertStringDoesNotContain added in v0.9.0

func AssertStringDoesNotContain(t *testing.T, str string, expected string)

func CleanEndings added in v0.10.0

func CleanEndings(s string) string

func ComputeSHA256ForFile

func ComputeSHA256ForFile(t *testing.T, path string) string

func CopyFile added in v0.9.0

func CopyFile(t *testing.T, srcFileName, destFileName string)

func CreateSingleFileTar

func CreateSingleFileTar(path, txt string) (io.Reader, error)

func DockerBuild added in v0.9.0

func DockerBuild(t *testing.T, name, context string, ops ...DockerCmdOp)

func DockerCli

func DockerCli(t *testing.T) dockercli.CommonAPIClient

func DockerContainerExists added in v0.9.2

func DockerContainerExists(t *testing.T, containerName string) bool

func DockerCopyOut added in v0.12.0

func DockerCopyOut(t *testing.T, containerName, srcCtrPath, outputDir string) string

func DockerImageRemove added in v0.9.0

func DockerImageRemove(t *testing.T, name string)

func DockerRun added in v0.9.0

func DockerRun(t *testing.T, image string, ops ...DockerCmdOp) string

func DockerRunAndCopy added in v0.9.0

func DockerRunAndCopy(t *testing.T, containerName, outputDir, outputCtrPath, image string, ops ...DockerCmdOp) string

DockerRunAndCopy runs a container and once stopped, outputCtrPath is copied to outputDir

func DockerRunWithCombinedOutput added in v0.15.0

func DockerRunWithCombinedOutput(t *testing.T, image string, ops ...DockerCmdOp) string

func DockerRunWithError added in v0.18.0

func DockerRunWithError(t *testing.T, image string, ops ...DockerCmdOp) (string, int, error)

DockerRunWithError allows to run docker command that might fail, reporting the error back to the caller

func DockerSeedRunAndCopy added in v0.12.0

func DockerSeedRunAndCopy(t *testing.T, containerName, srcDir, srcCtrPath, outputDir, outputCtrPath, image string, ops ...DockerCmdOp) string

DockerSeedRunAndCopy copies srcDir to container's srcCtrPath before container is started. Once stopped, outputCtrPath is copied to outputDir On WCOW, only works when seeding to container directory (not a mounted volume)

func DockerVolumeExists added in v0.9.2

func DockerVolumeExists(t *testing.T, volumeName string) bool

func DockerVolumeRemove added in v0.9.0

func DockerVolumeRemove(t *testing.T, volume string)

func Eventually

func Eventually(t *testing.T, test func() bool, every time.Duration, timeout time.Duration)

func GetUmask added in v0.12.0

func GetUmask(t *testing.T) int

func HTTPGetE

func HTTPGetE(url string) (string, error)

func MakeAndCopyLifecycle added in v0.9.0

func MakeAndCopyLifecycle(t *testing.T, goos, goarch, destDir string, envs ...string)

func Mkdir added in v0.10.0

func Mkdir(t *testing.T, dirs ...string)

func Mkfile added in v0.10.0

func Mkfile(t *testing.T, data string, paths ...string)

func MustReadFile

func MustReadFile(t *testing.T, path string) []byte

func PushImage added in v0.9.0

func PushImage(dockerCli dockercli.CommonAPIClient, ref string, auth string) error

FIXME: re-work this function to exec the docker cli, or convert other docker helpers to using the client library.

func RandString

func RandString(n int) string

func RandomLayer

func RandomLayer(t *testing.T, tmpDir string) (path string, sha string, contents []byte)

func Rdfile added in v0.10.0

func Rdfile(t *testing.T, path string) string

func ReadIndexManifest added in v0.17.0

func ReadIndexManifest(t *testing.T, path string) *v1.IndexManifest

func RecursiveCopy

func RecursiveCopy(t *testing.T, src, dst string)

func Run

func Run(t *testing.T, cmd *exec.Cmd) string

func RunE

func RunE(cmd *exec.Cmd) (output string, exitCode int, err error)

func RunWithCombinedOutput added in v0.15.0

func RunWithCombinedOutput(t *testing.T, cmd *exec.Cmd) string

func SeedDockerVolume added in v0.9.0

func SeedDockerVolume(t *testing.T, srcPath string) string

SeedDockerVolume only works with Linux daemons as Windows only mounts volumes for started containers

func SkipIf added in v0.9.0

func SkipIf(t *testing.T, expression bool, reason string)

func TempFile added in v0.15.0

func TempFile(t *testing.T, dir, pattern string) string

Types

type DockerCmd added in v0.9.0

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

type DockerCmdOp added in v0.9.0

type DockerCmdOp func(*DockerCmd)

func WithArgs added in v0.9.0

func WithArgs(args ...string) DockerCmdOp

func WithBash added in v0.9.0

func WithBash(args ...string) DockerCmdOp

func WithFlags added in v0.9.0

func WithFlags(flags ...string) DockerCmdOp

Jump to

Keyboard shortcuts

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