Documentation ¶
Overview ¶
Package testenv contains Environment for use in testing.
Index ¶
- func AssertNoError(t *testing.T, err error)
- func CheckNoError(t *testing.T, err error)
- func CreateDirectoryTree(dirname string, options DirectoryTreeOptions, counters *DirectoryTreeCounters) error
- func CreateRandomFile(filePath string, options DirectoryTreeOptions, counters *DirectoryTreeCounters) error
- func MustCreateDirectoryTree(t *testing.T, dirname string, options DirectoryTreeOptions)
- func MustCreateRandomFile(t *testing.T, filePath string, options DirectoryTreeOptions, ...)
- type CLITest
- func (e *CLITest) Cleanup(t *testing.T)
- func (e *CLITest) ListDirectory(t *testing.T, targets ...string) []DirEntry
- func (e *CLITest) ListSnapshotsAndExpectSuccess(t *testing.T, targets ...string) []SourceInfo
- func (e *CLITest) Run(t *testing.T, args ...string) (stdout, stderr []string, err error)
- func (e *CLITest) RunAndExpectFailure(t *testing.T, args ...string) []string
- func (e *CLITest) RunAndExpectSuccess(t *testing.T, args ...string) []string
- func (e *CLITest) RunAndExpectSuccessWithErrOut(t *testing.T, args ...string) (stdout, stderr []string)
- func (e *CLITest) RunAndProcessStderr(t *testing.T, callback func(line string) bool, args ...string) *exec.Cmd
- func (e *CLITest) RunAndVerifyOutputLineCount(t *testing.T, wantLines int, args ...string) []string
- type DirEntry
- type DirectoryTreeCounters
- type DirectoryTreeOptions
- type SnapshotInfo
- type SourceInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertNoError ¶
AssertNoError fails the test if a given error is not nil.
func CheckNoError ¶
CheckNoError fails the test if a given error is not nil.
func CreateDirectoryTree ¶
func CreateDirectoryTree(dirname string, options DirectoryTreeOptions, counters *DirectoryTreeCounters) error
CreateDirectoryTree creates a directory tree of a given depth with random files.
func CreateRandomFile ¶
func CreateRandomFile(filePath string, options DirectoryTreeOptions, counters *DirectoryTreeCounters) error
CreateRandomFile creates a new file at the provided path with randomized contents
func MustCreateDirectoryTree ¶
func MustCreateDirectoryTree(t *testing.T, dirname string, options DirectoryTreeOptions)
MustCreateDirectoryTree creates a directory tree of a given depth with random files.
func MustCreateRandomFile ¶
func MustCreateRandomFile(t *testing.T, filePath string, options DirectoryTreeOptions, counters *DirectoryTreeCounters)
MustCreateRandomFile creates a new file at the provided path with randomized contents. It will fail with a test error if the creation does not succeed.
Types ¶
type CLITest ¶
type CLITest struct { RepoDir string ConfigDir string Exe string Environment []string // contains filtered or unexported fields }
CLITest encapsulates state for a CLI-based test.
func NewCLITest ¶
NewCLITest creates a new instance of *CLITest
func (*CLITest) ListDirectory ¶
ListDirectory lists a given directory and returns directory entries.
func (*CLITest) ListSnapshotsAndExpectSuccess ¶
func (e *CLITest) ListSnapshotsAndExpectSuccess(t *testing.T, targets ...string) []SourceInfo
ListSnapshotsAndExpectSuccess lists given snapshots and parses the output.
func (*CLITest) RunAndExpectFailure ¶
RunAndExpectFailure runs the given command, expects it to fail and returns its output lines.
func (*CLITest) RunAndExpectSuccess ¶
RunAndExpectSuccess runs the given command, expects it to succeed and returns its output lines.
func (*CLITest) RunAndExpectSuccessWithErrOut ¶
func (e *CLITest) RunAndExpectSuccessWithErrOut(t *testing.T, args ...string) (stdout, stderr []string)
RunAndExpectSuccessWithErrOut runs the given command, expects it to succeed and returns its stdout and stderr lines.
type DirectoryTreeCounters ¶
type DirectoryTreeCounters struct { Files int Directories int TotalFileSize int64 MaxFileSize int64 }
DirectoryTreeCounters stores stats about files and directories created by CreateDirectoryTree
type DirectoryTreeOptions ¶
type DirectoryTreeOptions struct { Depth int MaxSubdirsPerDirectory int MaxFilesPerDirectory int MaxFileSize int MinNameLength int MaxNameLength int }
DirectoryTreeOptions lists options for CreateDirectoryTree
type SnapshotInfo ¶
SnapshotInfo represents a single snapshot information.
type SourceInfo ¶
type SourceInfo struct { User string Host string Path string Snapshots []SnapshotInfo }
SourceInfo reprents a single source (user@host:/path) with its snapshots.