test

package
v0.0.0-...-a8d7af0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyFile

func CopyFile(t *testing.T, srcPath, dstPath string)

CopyFile copies a file

func DeepEqual

func DeepEqual(a, b interface{}) bool

DeepEqual is a faster implementation of reflect.DeepEqual that:

  • Has a reflection-free fast-path for all the common types we use.
  • Gives data types the ability to exclude some of their fields from the consideration of DeepEqual by tagging them with `deepequal:"ignore"`.
  • Gives data types the ability to define their own comparison method by implementing the comparable interface.
  • Supports "composite" (or "complex") keys in maps that are pointers.

func Diff

func Diff(expected, actual interface{}) string

Diff returns the difference of two objects in a human readable format. An empty string is returned when there is no difference. To avoid confusing diffs, make sure you pass the expected value first.

func PrettyPrint

func PrettyPrint(v interface{}) string

PrettyPrint tries to display a human readable version of an interface

func PrettyPrintWithDepth

func PrettyPrintWithDepth(v interface{}, depth int) string

PrettyPrintWithDepth tries to display a human readable version of an interface and allows to define the depth of the print

func ShouldPanic

func ShouldPanic(t *testing.T, fn func())

ShouldPanic will test is a function is panicking

func ShouldPanicWith

func ShouldPanicWith(t *testing.T, msg interface{}, fn func())

ShouldPanicWith will test is a function is panicking with a specific message

func ShouldPanicWithStr

func ShouldPanicWithStr(t *testing.T, msg string, fn func())

ShouldPanicWithStr a function panics with a specific string. If the function panics with an error, the error's message is compared to the string.

func TempDir

func TempDir(t *testing.T, dirName string) string

TempDir creates a temporary directory under the default directory for temporary files (see os.TempDir) and returns the path of the new directory or fails the test trying.

Types

type DeepEqualer

type DeepEqualer interface {
	DeepEqual(other interface{}, comparer func(a, b interface{}) bool) bool
}

DeepEqualer allows collection types to compare their values using a given comparator.

Jump to

Keyboard shortcuts

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