Proposal: Support for Embedding in Mock
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 2.2k
- Forks
- 135
- Avg merge
- 11d 6h
- Merged PRs (30d)
- 1
Description
Certain interfaces may have a mechanism to guarantee that a specific type is embedded.
For example, the `Server` interface generated by `protoc-gen-go-grpc` contains an unexported `mustEmbedUnimplementedServer` method, which can be implemented by embedding the `UnimplementedServer` 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](https://pkg.go.dev/google.golang.org/grpc/examples/helloworld/helloworld) of grpc-go:
- https://github.com/grpc/grpc-go/blob/941102b7811f/examples/helloworld/helloworld/helloworld_grpc.pb.go#L72-L76
- https://github.com/grpc/grpc-go/blob/941102b7811f/examples/helloworld/helloworld/helloworld_grpc.pb.go#L83-L88
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?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the proposed embedding syntax and the protoc-gen-go-grpc future-proofing documentation, then inspect the linked helloworld_grpc.pb.go examples. The issue does not name moq files, tests, or an entry point, so the implementation scope and completion criteria need to be established before work begins.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- devtools, testing-qa
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100