internal

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCanNotRunIfNotBuiltinTesting = "This test is only supported on types of *testing.T"
)

Variables

View Source
var DiffContextLines = 2
View Source
var Highlight = pterm.NewStyle(pterm.FgLightRed).Sprint
View Source
var LineNumbersEnabled = true

LineNumbersEnabled controls if line numbers should be printed in the fail printer.

Functions

func AssertCompareHelper added in v0.2.8

func AssertCompareHelper(t testRunner, object any, option int, msg ...any)

AssertCompareHelper option: 1 = increasing, 0 = equal, -1 = decreasing

func AssertDirEmptyHelper added in v0.2.10

func AssertDirEmptyHelper(t testRunner, dir string) bool

AssertDirEmptyHelper checks for io.EOF to determine if directory empty or not

func AssertRegexpHelper added in v0.2.8

func AssertRegexpHelper(t testRunner, regex any, txt any, shouldMatch bool, msg ...any)

func CompareTwoValuesInASlice added in v0.2.8

func CompareTwoValuesInASlice(a reflect.Value, compareFunc func(a, b reflect.Value) bool) (ret bool)

CompareTwoValuesInASlice is a helper function.

func CompletesIn added in v0.2.9

func CompletesIn(duration time.Duration, f func()) bool

CompletesIn returns if a function completes in a specific time.

func DoesContain added in v0.2.9

func DoesContain(object, element any) bool

DoesContain checks that ab objects contains an element.

func Fail

func Fail(t testRunner, message string, objects Objects, args ...any)

func FailS

func FailS(message string, objects Objects, args ...any) string

func GetCurrentScriptDirectory added in v0.2.2

func GetCurrentScriptDirectory() string

GetCurrentScriptDirectory returns the directory of the current Go file.

func GetDifference

func GetDifference(a, b any, raw ...bool) string

GetDifference returns the diff for two projects.

func GetTest

func GetTest(t testRunner) *testing.T

GetTest converts to *testing.T.

func HasEqualValues added in v0.2.9

func HasEqualValues(expected any, actual any) bool

HasEqualValues checks if two objects have equal values.

func HasSameElements added in v0.2.13

func HasSameElements(expected any, actual any) bool

func IsEqual added in v0.2.9

func IsEqual(expected any, actual any) bool

IsEqual checks if two objects are equal.

func IsList added in v0.2.13

func IsList(list any) bool

func IsSubset added in v0.2.14

func IsSubset(t testRunner, list any, subset any) bool

func ModifyWrappedText

func ModifyWrappedText(text, wrappingString string, modifier func(wrappedText string) string) string

Types

type Object

type Object struct {
	Name      string
	NameStyle *pterm.Style
	Data      any
	DataStyle *pterm.Style
	Raw       bool
}

func NewDiffObject added in v0.3.2

func NewDiffObject(expected, actual any, raw ...bool) Object

type Objects

type Objects []Object

func NewObjectsExpectedActual

func NewObjectsExpectedActual(expected, actual any) Objects

func NewObjectsExpectedActualWithDiff added in v0.3.2

func NewObjectsExpectedActualWithDiff(expected, actual any) Objects

func NewObjectsSingleNamed

func NewObjectsSingleNamed(name string, obj any) Objects

func NewObjectsSingleUnknown

func NewObjectsSingleUnknown(obj any) Objects

func NewObjectsUnknown

func NewObjectsUnknown(objs ...any) Objects

Jump to

Keyboard shortcuts

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