testutil

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package testutil contains utilities used in tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetContainerMappedPortAddress added in v0.8.0

func GetContainerMappedPortAddress(t *testing.T, containerID, privatePort string) string

GetContainerMappedPortAddress returns <host>:<port> that can be used to connect to a given container and private port.

func GetInterestingTempDirectoryName added in v0.8.0

func GetInterestingTempDirectoryName() (string, error)

GetInterestingTempDirectoryName returns interesting directory name used for testing.

func MyTestMain added in v0.8.0

func MyTestMain(m *testing.M)

MyTestMain runs tests and verifies some post-run invariants.

func ProviderTest added in v0.8.0

func ProviderTest(t *testing.T)

ProviderTest marks the test method so that it only runs in provider-tests suite.

func Retry

func Retry(t *testing.T, testFun func(t *RetriableT))

Retry invokes the provided test multiple tests until it succeeds.

func RunContainerAndKillOnCloseOrSkip added in v0.8.0

func RunContainerAndKillOnCloseOrSkip(t *testing.T, args ...string) string

RunContainerAndKillOnCloseOrSkip runs "docker run" and ensures that resulting container is killed on exit. Returns containerID.

func RunDockerAndGetOutputOrSkip added in v0.8.0

func RunDockerAndGetOutputOrSkip(t *testing.T, args ...string) string

RunDockerAndGetOutputOrSkip runs Docker and returns the output as a string.

func ShouldReduceTestComplexity added in v0.8.0

func ShouldReduceTestComplexity() bool

ShouldReduceTestComplexity returns true if test complexity should be reduced on the current machine.

func TempDirectory added in v0.8.0

func TempDirectory(t *testing.T) string

TempDirectory returns an interesting temporary directory and cleans it up before test completes.

func TestSkipOnCIUnlessLinuxAMD64 added in v0.8.0

func TestSkipOnCIUnlessLinuxAMD64(t *testing.T)

TestSkipOnCIUnlessLinuxAMD64 skips the current test if running on CI unless the environment is Linux/AMD64.

func TestSkipUnlessCI added in v0.8.0

func TestSkipUnlessCI(t *testing.T, msg string, args ...interface{})

TestSkipUnlessCI skips the current test with a provided message, except when running in CI environment, in which case it causes hard failure.

Types

type RetriableT

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

RetriableT is a wrapper around *testing.T with the same methods that supports retrying tests.

func (*RetriableT) Error

func (t *RetriableT) Error(args ...interface{})

Error wraps testing.T.Error().

func (*RetriableT) Errorf

func (t *RetriableT) Errorf(msg string, args ...interface{})

Errorf wraps testing.T.Errorf().

func (*RetriableT) Fail

func (t *RetriableT) Fail()

Fail wraps testing.T.Fail().

func (*RetriableT) FailNow

func (t *RetriableT) FailNow()

FailNow wraps testing.T.FailNow().

func (*RetriableT) Fatal

func (t *RetriableT) Fatal(args ...interface{})

Fatal wraps testing.T.Fatal().

func (*RetriableT) Fatalf

func (t *RetriableT) Fatalf(msg string, args ...interface{})

Fatalf wraps testing.T.Fatalf().

func (*RetriableT) Skip

func (t *RetriableT) Skip(args ...interface{})

Skip wraps testing.T.Skip().

func (*RetriableT) Skipf

func (t *RetriableT) Skipf(msg string, args ...interface{})

Skipf wraps testing.T.Skipf().

Jump to

Keyboard shortcuts

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