test

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2018 License: BSD-2-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package test provides helper functions for writing tests for restic.

Index

Constants

This section is empty.

Variables

View Source
var (
	TestPassword                = getStringVar("RESTIC_TEST_PASSWORD", "geheim")
	TestCleanupTempDirs         = getBoolVar("RESTIC_TEST_CLEANUP", true)
	TestTempDir                 = getStringVar("RESTIC_TEST_TMPDIR", "")
	RunIntegrationTest          = getBoolVar("RESTIC_TEST_INTEGRATION", true)
	RunFuseTest                 = getBoolVar("RESTIC_TEST_FUSE", true)
	TestSFTPPath                = getStringVar("RESTIC_TEST_SFTPPATH", "/usr/lib/ssh:/usr/lib/openssh:/usr/libexec")
	TestWalkerPath              = getStringVar("RESTIC_TEST_PATH", ".")
	BenchArchiveDirectory       = getStringVar("RESTIC_BENCH_DIR", ".")
	TestS3Server                = getStringVar("RESTIC_TEST_S3_SERVER", "")
	TestRESTServer              = getStringVar("RESTIC_TEST_REST_SERVER", "")
	TestIntegrationDisallowSkip = getStringVar("RESTIC_TEST_DISALLOW_SKIP", "")
)

Functions

func Assert

func Assert(tb testing.TB, condition bool, msg string, v ...interface{})

Assert fails the test if the condition is false.

func Env

func Env(t testing.TB, repoFixture string) (repodir string, cleanup func())

Env creates a test environment and extracts the repository fixture. Returned is the repo path and a cleanup function.

func Equals

func Equals(tb testing.TB, exp, act interface{})

Equals fails the test if exp is not equal to act.

func OK

func OK(tb testing.TB, err error)

OK fails the test if an err is not nil.

func OKs

func OKs(tb testing.TB, errs []error)

OKs fails the test if any error from errs is not nil.

func Random

func Random(seed, count int) []byte

Random returns size bytes of pseudo-random data derived from the seed.

func RemoveAll

func RemoveAll(t testing.TB, path string)

RemoveAll recursively resets the read-only flag of all files and dirs and afterwards uses os.RemoveAll() to remove the path.

func ResetReadOnly

func ResetReadOnly(t testing.TB, dir string)

ResetReadOnly recursively resets the read-only flag recursively for dir. This is mainly used for tests on Windows, which is unable to delete a file set read-only.

func SetupTarTestFixture

func SetupTarTestFixture(t testing.TB, outputDir, tarFile string)

SetupTarTestFixture extracts the tarFile to outputDir.

func SkipDisallowed

func SkipDisallowed(t testing.TB, name string)

SkipDisallowed fails the test if it needs to run. The environment variable RESTIC_TEST_DISALLOW_SKIP contains a comma-separated list of test names that must be run. If name is in this list, the test is marked as failed.

func TempDir

func TempDir(t testing.TB) (path string, cleanup func())

TempDir returns a temporary directory that is removed when cleanup is called, except if TestCleanupTempDirs is set to false.

Types

type Helperer added in v0.9.0

type Helperer interface {
	Helper()
}

Helperer marks the current function as a test helper.

func Helper added in v0.9.0

func Helper(t testing.TB) Helperer

Helper returns a function that marks the current function as a helper function.

Jump to

Keyboard shortcuts

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