Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(all): simplify mocks generation #1413

Merged
merged 14 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
mockgen version used is the one defined in go.mod
- requires a `tools.go` blank importing golang.org/x/mod/semver in order to have the `golang.org/x/mod` dependency satisfied for mockgen v0.4
  • Loading branch information
qdm12 committed Jan 7, 2025
commit 52e1cdd8d618926cc765d7639b1bececa625f288
6 changes: 3 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ Mocks are auto-generated using [mockgen](https://pkg.go.dev/go.uber.org/mock/moc

- To **add** an interface that needs a corresponding mock generated:
- if the file `mocks_generate_test.go` exists in the package where the interface is located, either:
- modify its `//go:generate go run go.uber.org/mock/mockgen@v0.4` to generate a mock for your interface (preferred); or
- add another `//go:generate go run go.uber.org/mock/mockgen@v0.4` to generate a mock for your interface according to specific mock generation settings
- modify its `//go:generate go run go.uber.org/mock/mockgen` to generate a mock for your interface (preferred); or
- add another `//go:generate go run go.uber.org/mock/mockgen` to generate a mock for your interface according to specific mock generation settings
- if the file `mocks_generate_test.go` does not exist in the package where the interface is located, create it with content (adapt as needed):

```go
Expand All @@ -49,7 +49,7 @@ Mocks are auto-generated using [mockgen](https://pkg.go.dev/go.uber.org/mock/moc

package mypackage

//go:generate go run go.uber.org/mock/mockgen@v0.4 -package=${GOPACKAGE} -destination=mocks_test.go . YourInterface
//go:generate go run go.uber.org/mock/mockgen -package=${GOPACKAGE} -destination=mocks_test.go . YourInterface
```

Notes:
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ require (
go.uber.org/zap v1.26.0
golang.org/x/crypto v0.31.0
golang.org/x/exp v0.0.0-20231127185646-65229373498e
golang.org/x/mod v0.17.0
golang.org/x/sync v0.10.0
golang.org/x/sys v0.28.0
golang.org/x/text v0.21.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package interfaces

//go:generate go run go.uber.org/mock/mockgen@v0.4.0 -package=$GOPACKAGE -destination=mock_listener.go . StateCallbackListener
//go:generate go run go.uber.org/mock/mockgen -package=$GOPACKAGE -destination=mock_listener.go . StateCallbackListener
2 changes: 1 addition & 1 deletion precompile/contract/mocks_generate_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package contract

//go:generate go run go.uber.org/mock/mockgen@v0.4.0 -package=$GOPACKAGE -destination=mocks.go . BlockContext,AccessibleState,StateDB
//go:generate go run go.uber.org/mock/mockgen -package=$GOPACKAGE -destination=mocks.go . BlockContext,AccessibleState,StateDB
2 changes: 1 addition & 1 deletion precompile/precompileconfig/mocks_generate_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package precompileconfig

//go:generate go run go.uber.org/mock/mockgen@v0.4.0 -package=$GOPACKAGE -destination=mocks.go . Predicater,Config,ChainConfig,Accepter
//go:generate go run go.uber.org/mock/mockgen -package=$GOPACKAGE -destination=mocks.go . Predicater,Config,ChainConfig,Accepter
8 changes: 8 additions & 0 deletions tools.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// (c) 2025, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

package subnetevm

import (
_ "golang.org/x/mod/modfile" // golang.org/x/mod to satisfy requirement for go.uber.org/mock/mockgen@v0.4
)
2 changes: 1 addition & 1 deletion warp/aggregator/mocks_generate_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package aggregator

//go:generate go run go.uber.org/mock/mockgen@v0.4 -package=$GOPACKAGE -source=signature_getter.go -destination=mock_signature_getter.go -exclude_interfaces=NetworkClient
//go:generate go run go.uber.org/mock/mockgen -package=$GOPACKAGE -source=signature_getter.go -destination=mock_signature_getter.go -exclude_interfaces=NetworkClient