Skip to content

Commit

Permalink
fix: Improve mocks generation (#604)
Browse files Browse the repository at this point in the history
Since go 1.17 we can call external packages directly.

Co-authored-by: kokeshiM0chi <[email protected]>
  • Loading branch information
Kynea0b and Kynea0b authored May 9, 2023
1 parent 8261786 commit 0d8a0fd
Show file tree
Hide file tree
Showing 35 changed files with 208 additions and 59 deletions.
17 changes: 4 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,12 @@ install: $(LIBSODIUM_TARGET)
.PHONY: install

###############################################################################
### Mockery ###
### Mocks ###
###############################################################################

###
# https://github.com/vektra/mockery
# Should install
### brew
# brew install mockery
# brew upgrade mockery
### go get
# go get github.com/vektra/mockery/v2/.../

mock-gen:
go generate ./...
.PHONY: mock
mockery:
go generate -run="./scripts/mockery_generate.sh" ./...
.PHONY: mockery

###############################################################################
### Protobuf ###
Expand Down
4 changes: 3 additions & 1 deletion abci/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
tmsync "github.com/Finschia/ostracon/libs/sync"
)

//go:generate mockery --case underscore --name Client
const (
dialRetryIntervalSeconds = 3
echoRetryIntervalSeconds = 1
Expand All @@ -22,6 +21,9 @@ const (
// All `Sync` methods return the appropriate protobuf ResponseXxx struct and an error.
// Note these are client errors, eg. ABCI socket connectivity issues.
// Application-related errors are reflected in response via ABCI error codes and logs.
//
//go:generate ../../scripts/mockery_generate.sh Client

type Client interface {
service.Service

Expand Down
2 changes: 1 addition & 1 deletion abci/client/mocks/client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion abci/types/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/tendermint/tendermint/abci/types"
)

//go:generate mockery --case underscore --name Application
//go:generate ../../scripts/mockery_generate.sh Application

type CheckTxCallback func(ResponseCheckTx)

Expand Down
2 changes: 1 addition & 1 deletion abci/types/mocks/application.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion evidence/mocks/block_store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion evidence/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"github.com/Finschia/ostracon/types"
)

//go:generate mockery --case underscore --name BlockStore
//go:generate ../scripts/mockery_generate.sh BlockStore

type BlockStore interface {
LoadBlockMeta(height int64) *types.BlockMeta
Expand Down
20 changes: 14 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ require (

require (
github.com/rs/zerolog v1.29.1
github.com/vektra/mockery/v2 v2.26.1
gopkg.in/natefinch/lumberjack.v2 v2.2.1
)

Expand All @@ -61,6 +62,7 @@ require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chigopher/pathlib v0.13.0 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d // indirect
github.com/cosmos/gorocksdb v1.2.0 // indirect
Expand All @@ -71,18 +73,22 @@ require (
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/frankban/quicktest v1.14.4 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/btree v1.0.0 // indirect
github.com/gtank/ristretto255 v0.1.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/iancoleman/strcase v0.2.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jinzhu/copier v0.3.5 // indirect
github.com/jmhodges/levigo v1.0.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
Expand All @@ -93,7 +99,7 @@ require (
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.9.0 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
Expand All @@ -102,12 +108,14 @@ require (
github.com/subosito/gotenv v1.4.2 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca // indirect
go.etcd.io/bbolt v1.3.6 // indirect
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/exp v0.0.0-20230212135524-a684f29349b6 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/tools v0.6.0 // indirect
golang.org/x/tools v0.7.0 // indirect
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Loading

0 comments on commit 0d8a0fd

Please sign in to comment.