test

package
v0.40.4 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package test provides utility methods and classes for testing.

Index

Constants

View Source
const (
	// ShouldNeverHappen is only seen when the impossible happens.
	ShouldNeverHappen = "http://www.nooooooooooooooo.com"
)

Variables

This section is empty.

Functions

func ChangeToTestDir

func ChangeToTestDir(testName string) (string, error)

ChangeToTestDir creates a new test directory and changes the current directory to be

func RandomData

func RandomData(size int) []byte

RandomData returns a slice of a given size filled with random data

func TestDir

func TestDir(testName string) string

TestDir creates a subdirectory inside the systems temp directory

Types

type TestError

type TestError struct {
	ErrId uuid.UUID
}

TestError is an error that stores a uniquely generated id

func NewTestError

func NewTestError() *TestError

NewTestError creates a TestError with a newly created id

func (*TestError) Error

func (te *TestError) Error() string

Error is the only method defined in the error interface

type TestReader

type TestReader struct {
	// contains filtered or unexported fields
}

TestReader is an io.Reader that will error after some number of bytes have been read

func NewTestReader

func NewTestReader(dataSize, errorAfter int) *TestReader

NewTestReader takes a size, and the number of bytes that should be read before the reader errors. The size is used to generate a buffer of random data that will be read by the caller. After the caller has read the specified number of bytes the call to read will fail.

func NewTestReaderWithData

func NewTestReaderWithData(data []byte, errorAfter int) *TestReader

NewTestReaderWithData creates a TestReader with user supplied data and the number of bytes that can be read before errors start occurring on Read calls.

func (*TestReader) Read

func (tr *TestReader) Read(p []byte) (int, error)

Read reads data from the internal buffer

Jump to

Keyboard shortcuts

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