We use mockgen, from golang/mock.
# Note: this may take over a minute, with no output.
make mocksThe Makefile target runs go generate, which looks for comments of the form
//go:generate.
Because these comments have go run github.com/golang/mock/mockgen as the
command, there is no need to run go get or go install to fetch or install
mockgen.
The file candles/service.go has:
//go:generate go run github.com/golang/mock/mockgen -destination mocks/candle_store_mock.go -package mocks code.vegaprotocol.io/data-node/candles CandleStore
type CandleStore interface { /* ... */ }In order to recreate just the candle mocks:
cd .../go/src/data-node/candles
rm -rf mocks
go generate .
git diff # hopefully no differencesTo run all tests, use:
make testTo run tests from one subdirectory, use:
go test ./somedir/To force a re-run of previously successful tests, add -count 1.
TBD (#230)