test

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CatchExpectedError

func CatchExpectedError(err any, t *testing.T)

CatchExpectedError function is a helper function for use in unit tests. It expects an error value as its first argument, and a pointer to a testing.T struct as its second argument. If the error is not nil, the function logs the error and continues execution of the unit test. If the error is nil, the function panics with a message indicating that the code did not panic as expected. This function is used to verify that a particular code path produces an error in a unit test.

Types

type MemoryBuffer

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

MemoryBuffer has both Write and Close methods for use as io.WriteCloser when testing (instead of os.Stdout), so tests can assert.Equal results etc.

func NewMemoryBuffer

func NewMemoryBuffer() *MemoryBuffer

func (*MemoryBuffer) Close

func (b *MemoryBuffer) Close() error

func (*MemoryBuffer) String

func (b *MemoryBuffer) String() string

func (*MemoryBuffer) Write

func (b *MemoryBuffer) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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