utils

package
v0.0.0-...-795b9e8 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MustMatch = MustMatchFn()

MustMatch is a convenience version of MustMatchFn with no overrides. Usage in Test*() function:

testutils.MustMatch(t, want, got, "something doesn't match")

Functions

func MakeTestOutput

func MakeTestOutput(t *testing.T, dir, pattern string) string

func MustMatchFn

func MustMatchFn(ignoredFields ...string) func(t *testing.T, want, got any, errMsg ...string)

MustMatchFn is used to create a common diff function for a test file Usage in *_test.go file:

Top declaration:

var mustMatch = testutils.MustMatchFn(

[]any{  // types with unexported fields
	type1{},
	type2{},
	...
	typeN{},
},
[]string{  // ignored fields
	".id",        // id numbers are unstable
	".createAt",  // created dates might not be interesting to compare
},

)

In Test*() function:

mustMatch(t, want, got, "something doesn't match")

func MustMatchPB

func MustMatchPB(t *testing.T, expected string, pb proto.Message)

func SortString

func SortString(w string) string

SortString sorts the string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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