assertions

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(tb testing.TB, condition bool, msg string, v ...interface{})

Assert fails the test if the condition is false with tb.Fail

Example
assertions.Assert(&mockTB{}, 3 == 4, "custom message %s%s", "custom str 2", "custom strings")
Output:

�[31mexample_assertions_test.go:20: custom message custom str 2custom strings�[39m

func AssertNow

func AssertNow(tb testing.TB, condition bool, msg string, v ...interface{})

AssertNow fails the test if the condition is false with tb.FailNow

Example
assertions.AssertNow(&mockTB{}, 3 == 4, "custom message %s%s", "custom str 2", "custom strings")
Output:

�[31mexample_assertions_test.go:25: custom message custom str 2custom strings�[39m

func Equals

func Equals(tb testing.TB, exp, act interface{})

Equals fails the test if exp is not equal to act

Example (Int)
assertions.Equals(&mockTB{}, 44, 23)
/* Output: �[31mexample_assertions_test.go:30:

exp: 44

got: 23�[39m
*/
Output:

�[31mexample_assertions_test.go:30:

	exp: 44

	got: 23�[39m
Example (Map)
map1 := map[string]int{"dsds": 33, "lol": 420}
map2 := map[string]int{"dsds": 3, "ll": 420}
assertions.Equals(&mockTB{}, map1, map2)
/* Output: �[31mexample_assertions_test.go:42:

exp: map[string]int{"dsds":33, "lol":420}

got: map[string]int{"dsds":3, "ll":420}�[39m
*/
Output:

�[31mexample_assertions_test.go:42:

	exp: map[string]int{"dsds":33, "lol":420}

	got: map[string]int{"dsds":3, "ll":420}�[39m

func EqualsNow

func EqualsNow(tb testing.TB, exp, act interface{})

EqualsNow fails the test if exp is not equal to act

func Ok

func Ok(tb testing.TB, err error)

Ok checks for unexpected errors (if err is not nil)

Example
assertions.Ok(&mockTB{}, errors.New("example error"))
Output:

�[31mexample_assertions_test.go:10: unexpected error: example error�[39m

func OkNow

func OkNow(tb testing.TB, err error)

OkNow checks for unexpected errors (if err is not nil)

Example
assertions.OkNow(&mockTB{}, errors.New("example error"))
Output:

�[31mexample_assertions_test.go:15: unexpected error: example error�[39m

Types

This section is empty.

Jump to

Keyboard shortcuts

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