Skip to content

Proposal: Support for Embedding in Mock #226

Open
@frozenbonito

Description

@frozenbonito

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions