We use mockgen
, from golang/mock
.
# Note: this may take over a minute, with no output.
make mocks
The 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/vega/candles CandleStore
type CandleStore interface { /* ... */ }
In order to recreate just the candle mocks:
cd .../go/src/vega/candles # trading-core
rm -rf mocks
go generate .
git diff # hopefully no differences
To run all tests, use:
make test
To run tests from one subdirectory, use:
go test ./somedir/
To force a re-run of previously successful tests, add -count 1
.
TBD (#230)