testutils

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Equal

func Equal[V comparable](tt TestingIface, expected, actual V, msgAndArgs ...any) bool

Equal asserts comparables.

testutils.Equal(t, "hello", "hello")

func EqualAny

func EqualAny(tt TestingIface, expected, actual any, msgAndArgs ...any) bool

func EqualAnyf

func EqualAnyf(tt TestingIface, expected any, actual any, msg string, args ...any) bool

func Error

func Error(tt TestingIface, err error, msgAndArgs ...any) bool

Error assert that err != nil

func ErrorIs

func ErrorIs(tt TestingIface, err, target error, msgAndArgs ...any) bool

ErrorIs asserts errors.Is(err, target)

func False

func False(tt TestingIface, value bool, msgAndArgs ...any) bool

False asserts that the specified value is false.

testutils.False(t, myBool)

func KeyValErrorMsg

func KeyValErrorMsg(key string, val any) string

func Nil

func Nil(tt TestingIface, value any, msgAndArgs ...any) bool

func NoError

func NoError(ti TestingIface, err error, msgAndArgs ...any) bool

NoError asserts that a function returned no error (i.e. `nil`).

  actualObj, err := SomeFunction()
  if testutils.NoError(t, err) {
	   testutils.Equal(t, expectedObj, actualObj)
  }

func NotEqual

func NotEqual[V comparable](tt TestingIface, expected, actual V, msgAndArgs ...any) bool

func NotNil

func NotNil(tt TestingIface, value any, msgAndArgs ...any) bool

NotNil asserts that the specified value is not nil.

testutils.NotNil(t, &val)

func ObjectsAreEqual

func ObjectsAreEqual(expected, actual interface{}) bool

ObjectsAreEqual determines if two objects are considered equal.

This function does no assertion of any kind.

func True

func True(tt TestingIface, value bool, msgAndArgs ...any) bool

True asserts that the specified value is true.

testutils.True(t, myBool)

Types

type TestingIface

type TestingIface interface {
	Errorf(format string, args ...any)
	Name() string
	Helper()
}

TestingIface is an interface wrapper for *testing.T, *testing.B, *testing.F

Jump to

Keyboard shortcuts

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