test_helper

package
v0.0.0-...-17ee6b1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2015 License: BSD-2-Clause Imports: 14 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

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 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 System

func System(command string, args ...string) error

System runs the command and returns the exit code. Output is passed on to stdout/stderr.

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