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

Proposal: Support for Embedding in Mock #226

Open
frozenbonito opened this issue Sep 28, 2024 · 1 comment · May be fixed by #227
Open

Proposal: Support for Embedding in Mock #226

frozenbonito opened this issue Sep 28, 2024 · 1 comment · May be fixed by #227

Comments

@frozenbonito
Copy link

Certain interfaces may have a mechanism to guarantee that a specific type is embedded.

For example, the <ServiceName>Server interface generated by protoc-gen-go-grpc contains an unexported mustEmbedUnimplemented<ServiceName>Server method, which can be implemented by embedding the Unimplemented<ServiceName>Server from the same package.

You can find more information here:
https://github.com/grpc/grpc-go/tree/master/cmd/protoc-gen-go-grpc#future-proofing-services

Real examples can be seen in the helloworld example of grpc-go:

To support this pattern, I propose a feature that allows specified types to be embedded in mocks. For instance, how about running moq -out mocks_test.go . MyInterface{Type1,Type2} (or MyInterface:MyMock{Type1,Type2}) to embed Type1 and Type2 in MyInterface mock?

@frozenbonito frozenbonito linked a pull request Sep 29, 2024 that will close this issue
@tigerquoll
Copy link

I am seeing the same bug in my code - any recent GRPC generated code will potentially be hit the same way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants