testutil

package
v1.25.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Overview

Package testutil implements various utilities to reduce boilerplate in unit tests a la testify.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AreProtoEqual added in v1.15.0

func AreProtoEqual[T proto.Message](expected T, found T, message string, args ...any) error

AreProtoEqual returns whether the expected and required protocol buffer messages are equal, via proto.Equal. If the messages are not equal, returns an error.

func AreProtoSlicesEqual added in v1.15.0

func AreProtoSlicesEqual[T proto.Message](expected []T, found []T, sorter SortFunction[T], message string, args ...any) error

AreProtoSlicesEqual returns whether the slices of protocol buffers are equal via protocol buffer comparison.

func RequireEqualEmptyNil

func RequireEqualEmptyNil(t *testing.T, expected, actual interface{}, msgAndArgs ...interface{})

RequireEqualEmptyNil is a version of require.Equal, but considers nil slices/maps to be equal to empty slices/maps.

func RequireProtoEqual added in v1.15.0

func RequireProtoEqual[T proto.Message](t *testing.T, expected T, found T, message string, args ...any)

RequireProtoEqual ensures that the expected and required protocol buffer messages are equal, via proto.Equal.

func RequireProtoSlicesEqual added in v1.15.0

func RequireProtoSlicesEqual[T proto.Message](t *testing.T, expected []T, found []T, sorter SortFunction[T], message string, args ...any)

RequireProtoSlicesEqual ensures that the expected slices of protocol buffers are equal. The sort function is used to sort the messages before comparison.

func RequireWithin added in v1.16.1

func RequireWithin(t *testing.T, runner func(t *testing.T), timeout time.Duration)

RequireWithin requires that the runner complete its execution within the specified duration.

Types

type SortFunction added in v1.15.0

type SortFunction[T proto.Message] func(first T, second T) int

SortFunction is a sorting function used for ordering two protocol buffers. Returns an integer representing the order, same as strings.Compare.

Jump to

Keyboard shortcuts

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