Skip to content

Commit 2b7fdc6

Browse files
authored
Record sei-cosmos mockgen commands as go:generate directives (#4622)
The mocks under `sei-cosmos/tests/mocks` are committed MockGen output that tests still import, but the only record of how to regenerate them was the `mocks` target in `sei-cosmos/Makefile`, which was deleted along with the rest of that Makefile. This adds `sei-cosmos/tests/mocks/generate.go` with `go:generate` directives for the four source-mode mocks (account retriever, module, invariant, router), pinned to the `golang/mock` version already in `go.mod`, so `go generate ./sei-cosmos/tests/mocks/` rebuilds them. Running it brought `types_module_module.go` up to date: `MockAppModule` had stale hand-kept `BeginBlock`/`MidBlock` methods that `AppModule` no longer declares, and `MockEndBlockAppModule` lacked `EndBlock`. `TestManager_MidBlock` now uses `MockMidBlockAppModule`, which is what `Manager.MidBlock` actually type-asserts on. The other three files only change their `Source:` header line. The handler mock is hand-edited to call the next ante handler and the package-mode mocks (tm-db, gogo grpc, Tendermint logger) point at upstream paths, so they are left as they are. Test-only change; the `sei-cosmos/types`, `client` and `store/dbadapter` tests pass.
1 parent fd0f570 commit 2b7fdc6

6 files changed

Lines changed: 26 additions & 31 deletions

File tree

‎sei-cosmos/tests/mocks/account_retriever.go‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎sei-cosmos/tests/mocks/generate.go‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package mocks
2+
3+
//go:generate go run github.com/golang/mock/mockgen@v1.7.0-rc.1 -source=../../client/account_retriever.go -package mocks -destination account_retriever.go
4+
//go:generate go run github.com/golang/mock/mockgen@v1.7.0-rc.1 -source=../../types/module/module.go -package mocks -destination types_module_module.go
5+
//go:generate go run github.com/golang/mock/mockgen@v1.7.0-rc.1 -source=../../types/invariant.go -package mocks -destination types_invariant.go
6+
//go:generate go run github.com/golang/mock/mockgen@v1.7.0-rc.1 -source=../../types/router.go -package mocks -destination types_router.go

‎sei-cosmos/tests/mocks/types_invariant.go‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎sei-cosmos/tests/mocks/types_module_module.go‎

Lines changed: 15 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎sei-cosmos/tests/mocks/types_router.go‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎sei-cosmos/types/module/module_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ func TestManager_MidBlock(t *testing.T) {
277277
mockCtrl := gomock.NewController(t)
278278
t.Cleanup(mockCtrl.Finish)
279279

280-
mockAppModule1 := mocks.NewMockAppModule(mockCtrl)
281-
mockAppModule2 := mocks.NewMockAppModule(mockCtrl)
280+
mockAppModule1 := mocks.NewMockMidBlockAppModule(mockCtrl)
281+
mockAppModule2 := mocks.NewMockMidBlockAppModule(mockCtrl)
282282
mockAppModule1.EXPECT().Name().Times(2).Return("module1")
283283
mockAppModule2.EXPECT().Name().Times(2).Return("module2")
284284
mm := module.NewManager(mockAppModule1, mockAppModule2)

0 commit comments

Comments
 (0)