From bcb6fc7f7179bf6e58081d702e598bf9433c35f9 Mon Sep 17 00:00:00 2001 From: Marius Date: Fri, 14 Oct 2016 11:52:51 +0200 Subject: [PATCH] Add comments to test utilities --- utils_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/utils_test.go b/utils_test.go index 83eb811..93d96ce 100644 --- a/utils_test.go +++ b/utils_test.go @@ -13,6 +13,14 @@ import ( "github.com/tus/tusd" ) +//go:generate mockgen -package tusd_test -source utils_test.go -aux_files tusd=datastore.go -destination=handler_mock_test.go + +// FullDataStore is an interface combining most interfaces for data stores. +// This is used by mockgen(1) to generate a mocked data store used for testing +// (see https://github.com/golang/mock). The only interface excluded is +// LockerDataStore because else we would have to explicitly expect calls for +// locking in every single test which would result in more verbose code. +// Therefore it has been moved into its own type definition, the Locker. type FullDataStore interface { tusd.DataStore tusd.TerminaterDataStore @@ -74,6 +82,9 @@ type readerMatcher struct { expect string } +// NewReaderMatcher returns a gomock.Matcher which can be used in tests for +// expecting io.Readers as arguments. It will only report an argument x as +// matching if it's an io.Reader which, if fully read, equals the string `expect`. func NewReaderMatcher(expect string) gomock.Matcher { return readerMatcher{ expect: expect,