You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What operating system (Linux, Windows, …) and version?
macOS
What did you do?
We are using mockery for unittests for our handlers.
Mockery needs the interface to know what to mock and then create the corresponding mocking files that we can then use in unittests to make testing a bit easier. e.g.
New generic types introduced in protoc-gen-go-grpc v1.5.0 has a change tha no longer defines the interfaces but just assigns the type to a generic interface. Although this still works in the implementation of the handler, it no longer works for tools like mockery to detect it. I already tried, without success, to see if the new type could be used for unittests.
Fortunately a flag was introduced to disable this feature which I appreciate a lot, but just raising our use case so that we can discuss and see if we could bring this old implementation back.
What did you expect to see?
Keep defining Streaming interfaces instead of generic ones.
What did you see instead?
New server uses generic types which is no longer compatible with mock tool.
The text was updated successfully, but these errors were encountered:
Hi @cesnietor, we intend to keep the code generation using generics as it simplifies the code generation process and the generated code. Maybe you could ask mockery devs to support generic interfaces?
I found this issue that may be similar to the one you're seeing: vektra/mockery#787
We do plan to remove the flag for the old behaviour in an upcoming release of protoc-gen-go-grpc.
Just wanted to add: from personal experience, mocking RPC handlers can be problematic, as it assumes the behavior of gRPC, which might not match your expectations in all cases. I would highly recommend changing your testing approach to use a fake server implementation (or client?) with a real gRPC channel instead. Or refactor and unit test smaller pieces if that's the style you prefer. Let us know if you need any help with that, or if you need a better explanation of the approach or justification.
What version of gRPC are you using?
protobuf 28.0
protoc-gen-go-grpc v1.5.1
What version of Go are you using (
go version
)?go version go1.22.5 darwin/arm64
What operating system (Linux, Windows, …) and version?
macOS
What did you do?
We are using mockery for unittests for our handlers.
Mockery needs the interface to know what to mock and then create the corresponding mocking files that we can then use in unittests to make testing a bit easier. e.g.
New generic types introduced in protoc-gen-go-grpc v1.5.0 has a change tha no longer defines the interfaces but just assigns the type to a generic interface. Although this still works in the implementation of the handler, it no longer works for tools like mockery to detect it. I already tried, without success, to see if the new type could be used for unittests.
Fortunately a flag was introduced to disable this feature which I appreciate a lot, but just raising our use case so that we can discuss and see if we could bring this old implementation back.
What did you expect to see?
Keep defining Streaming interfaces instead of generic ones.
What did you see instead?
New server uses generic types which is no longer compatible with mock tool.
The text was updated successfully, but these errors were encountered: