util

package
v0.0.0-...-71c93ef Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Any = Anything{} //nolint:gochecknoglobals // This is a special value, not intended to be modified.

Any is a special value that can be used to match any argument.

Functions

func ErrorContains

func ErrorContains(contains string) assert.ErrorAssertionFunc

ErrorContains returns an assertion to check if the error contains the given string.

func ErrorIs

func ErrorIs(target error) assert.ErrorAssertionFunc

ErrorIs returns an assertion to check if the error is the target error.

func HasIntersection

func HasIntersection(sliceOne, sliceTwo []string) bool

HasIntersection checks if two slices have any common elements.

func RandomHex

func RandomHex(n int) (string, error)

RandomHex generates an n-length, random hex string.

Types

type Anything

type Anything struct{}

Anything is a special type that can be used to match any argument.

type FileSize

type FileSize struct {
	Unit string
	Size int
}

FileSize represents a file size with units.

func FileSizeFromSize

func FileSizeFromSize(size int) FileSize

FileSizeFromSize returns a FileSize instance from the given size.

func (FileSize) String

func (f FileSize) String() string

String returns the string representation of the file size.

type InAndOut

type InAndOut struct {
	Skip  int
	Calls int
	In    []interface{}
	Out   error
}

InAndOut represents the input arguments and return value of a method.

type Spy

type Spy struct {
	Methods map[string][]InAndOut
	// contains filtered or unexported fields
}

Spy is a test spy that can be used to record method calls and their arguments.

func NewSpy

func NewSpy() *Spy

NewSpy creates a new Spy.

func (*Spy) GetError

func (s *Spy) GetError(method string, args ...interface{}) error

GetError returns a pre-defined error for a given method and arguments.

func (*Spy) Register

func (s *Spy) Register(method string, skip int, err error, args ...interface{}) *Spy

Register registers a method with its arguments and return value.

func (*Spy) Reset

func (s *Spy) Reset()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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