then

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(t *testing.T, sub, full string)

Contains checks if our substring is contained in the full string

func Equals

func Equals[T comparable](t *testing.T, expected, actual T)

Equals compares two values, in some rare cases due to generic limitations you may have to use `reflect.DeepEquals` instead.

func Err

func Err(t *testing.T, expected, actual error)

Err checks if our actual error is the expected error or wrapped in the expected error.

func False

func False(t *testing.T, value bool)

False checks if a value is false.

func MapEquals

func MapEquals[M1, M2 ~map[K]V, K, V comparable](t *testing.T, expected M1, actual M2)

MapEquals compares two map values for same length and same key+value pairs.

func Nil

func Nil(t *testing.T, value any)

Nil compares a value to nil, in some cases you may need to do `Equals(t, value, nil)`

func NotEqual

func NotEqual[T comparable](t *testing.T, expected, actual T)

NotEquals compares two values are not equal

func NotNil

func NotNil(t *testing.T, value any)

NotNil compares a value is not nil.

func Panic

func Panic(t *testing.T, f func())

Panic checks if our func would panic.

func RunFromDir added in v0.1.0

func RunFromDir(t *testing.T, relativeDirChange string)

RunFromDir will change our directory temporarily for a test

func SliceEquals

func SliceEquals[T comparable](t *testing.T, expected, actual []T)

SliceEquals compares two slices for same length and same values at each index.

func True

func True(t *testing.T, value bool)

True checks if a value is true.

Types

type CountWriter

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

CountWriter is a simple struct that will successfully write to a byte buffer a specified number of times, and then it will error

func NewCountWriter

func NewCountWriter(count int) *CountWriter

func (*CountWriter) Raised

func (w *CountWriter) Raised(t *testing.T, err error)

Raised will assert the error value is the one we would of returned if Write was called too many times.

func (*CountWriter) Write

func (w *CountWriter) Write(value []byte) (int, error)

type ErrWriter

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

ErrWriter is a simple struct that will return an error when trying to Write

func NewErrWriter

func NewErrWriter() *ErrWriter

func (*ErrWriter) Raised

func (w *ErrWriter) Raised(t *testing.T, err error)

Raised will assert the error value is the one we would of returned if Write was called.

func (*ErrWriter) Write

func (w *ErrWriter) Write(data []byte) (int, error)

Jump to

Keyboard shortcuts

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