testutil

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package testutil contains test utilities.

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 MustGetTotalDirSize added in v0.10.7

func MustGetTotalDirSize(t *testing.T, dirpath string) int64

MustGetTotalDirSize computes the total size of a directory.

func MustParseJSONLines added in v0.9.0

func MustParseJSONLines(t *testing.T, lines []string, v interface{})

MustParseJSONLines parses the lines containing JSON into the provided object.

func MyTestMain added in v0.8.0

func MyTestMain(m *testing.M, cleanups ...func())

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 RunAllTestsWithParam added in v0.9.0

func RunAllTestsWithParam(t *testing.T, v interface{})

RunAllTestsWithParam uses reflection to run all test methods starting with 'Test' on the provided object.

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(tb testing.TB, 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 ShouldSkipLongFilenames added in v0.9.1

func ShouldSkipLongFilenames() bool

ShouldSkipLongFilenames returns true if: an environmental variable is unset, set to false, test is running on ARM, or if running race detection.

func ShouldSkipUnicodeFilenames added in v0.9.1

func ShouldSkipUnicodeFilenames() bool

ShouldSkipUnicodeFilenames returns true if: an environmental variable is unset, set to false, test is running on ARM, or if running race detection.

func SkipNonDeterministicTestUnderCodeCoverage added in v0.10.7

func SkipNonDeterministicTestUnderCodeCoverage(t *testing.T)

SkipNonDeterministicTestUnderCodeCoverage skips the non-deterministic test for a code coverage run.

func TempDirectory added in v0.8.0

func TempDirectory(tb testing.TB) string

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

func TempDirectoryShort added in v0.14.0

func TempDirectoryShort(tb testing.TB) string

TempDirectoryShort returns a short temporary directory and cleans it up before test completes.

func TempLogDirectory added in v0.9.0

func TempLogDirectory(t *testing.T) string

TempLogDirectory returns a temporary directory used for storing logs. If KOPIA_LOGS_DIR is provided.

func TestSkipOnCIUnlessLinuxAMD64 added in v0.8.0

func TestSkipOnCIUnlessLinuxAMD64(tb testing.TB)

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

func TestSkipUnlessCI added in v0.8.0

func TestSkipUnlessCI(tb testing.TB, 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.

func TestSkipUnlessLinux added in v0.10.7

func TestSkipUnlessLinux(tb testing.TB)

TestSkipUnlessLinux skips the current test if the test environment is not Linux.

Types

type ServerParameters added in v0.10.2

type ServerParameters struct {
	BaseURL               string
	SHA256Fingerprint     string
	Password              string
	ServerControlPassword string
}

ServerParameters encapsulates parameters captured by processing stderr of 'kopia server start'.

func (*ServerParameters) ProcessOutput added in v0.10.2

func (s *ServerParameters) ProcessOutput(l string) bool

ProcessOutput processes output lines from a server that's starting up.

Jump to

Keyboard shortcuts

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