test_helper

package
v0.1.0-doc Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2016 License: BSD-2-Clause Imports: 17 Imported by: 0

Documentation

Overview

Package test_helper provides helper functions for writing tests for restic.

Index

Constants

This section is empty.

Variables

View Source
var (
	TestPassword          = getStringVar("RESTIC_TEST_PASSWORD", "geheim")
	TestCleanup           = 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")
	TestWalkerPath        = getStringVar("RESTIC_TEST_PATH", ".")
	BenchArchiveDirectory = getStringVar("RESTIC_BENCH_DIR", ".")
)

Functions

func Assert

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

Assert fails the test if the condition is false.

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 OpenLocalRepo

func OpenLocalRepo(t testing.TB, dir string) *repository.Repository

OpenLocalRepo opens the local repository located at dir.

func ParseID

func ParseID(s string) backend.ID

ParseID parses s as a backend.ID and panics if that fails.

func Random

func Random(seed, count int) []byte

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

func RandomReader

func RandomReader(seed, size int) *bytes.Reader

RandomReader returns a reader that 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 SetupRepo

func SetupRepo() *repository.Repository

func SetupTarTestFixture

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

SetupTarTestFixture extracts the tarFile to outputDir.

func SnapshotDir

func SnapshotDir(t testing.TB, repo *repository.Repository, path string, parent *backend.ID) *restic.Snapshot

func TeardownRepo

func TeardownRepo(repo *repository.Repository)

func WithRepo

func WithRepo(t testing.TB, f func(*repository.Repository))

func WithTestEnvironment

func WithTestEnvironment(t testing.TB, repoFixture string, f func(repodir string))

WithTestEnvironment creates a test environment, extracts the repository fixture and and calls f with the repository dir.

Types

This section is empty.

Jump to

Keyboard shortcuts

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