Documentation ¶
Overview ¶
Package test contains utility methods for testing.
Index ¶
- Variables
- func ByteSlicesBackedBySameData(a, b []byte) bool
- func CmpMatcher(x interface{}, opts ...cmp.Option) gomock.Matcher
- func Diff(expected, actual string) string
- func NewCorruptingFile(fd xos.File, corruptionProbability float64, seed int64) xos.File
- func NewLogger(t *testing.T) *zap.Logger
- type Reporter
Constants ¶
This section is empty.
Variables ¶
var IdentTransformer = cmp.Transformer("", func(id ident.ID) ident.BytesID { return ident.BytesID(id.Bytes()) })
IdentTransformer transforms any ident.ID into ident.BytesID to make it easier for comparison.
Functions ¶
func ByteSlicesBackedBySameData ¶
ByteSlicesBackedBySameData returns a bool indicating if the raw backing bytes under the []byte slice point to the same memory.
func CmpMatcher ¶ added in v0.8.2
CmpMatcher returns a new matcher backed by go-cmp/cmp.Equal.
func Diff ¶
Diff is a helper method to print a terminal pretty diff of two strings for test output purposes.
func NewCorruptingFile ¶ added in v0.4.8
NewCorruptingFile creates a new corrupting file.
Types ¶
type Reporter ¶ added in v0.8.2
Reporter wraps a *testing.T, and provides a more useful failure mode when interacting with gomock.Controller.
For example, consider:
func TestMyThing(t *testing.T) { mockCtrl := gomock.NewController(t) defer mockCtrl.Finish() mockObj := something.NewMockMyInterface(mockCtrl) go func() { mockObj.SomeMethod(4, "blah") } }
It hangs without any indication that it's missing an EXPECT() on `mockObj`. Providing the Reporter to the gomock.Controller ctor avoids this, and terminates with useful feedback. i.e.
func TestMyThing(t *testing.T) { mockCtrl := gomock.NewController(test.Reporter{t}) defer mockCtrl.Finish() mockObj := something.NewMockMyInterface(mockCtrl) go func() { mockObj.SomeMethod(4, "blah") // crashes the test now } }
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package testmarshal provides some assertions around marshalling/unmarshalling (serialization/deserialization) behavior for types.
|
Package testmarshal provides some assertions around marshalling/unmarshalling (serialization/deserialization) behavior for types. |