Closed veqryn closed 5 years ago
Hey @veqryn do you know if this is still an issue for you? It looks like some work was done that might have solved this.
I ran the above code and the generated mock is now func (m *MockHelloClient) EnglishHello(arg0 context.Context, arg1 *proto.HelloReq, arg2 ...grpc.CallOption) (*proto.HelloResp, error)
. Closing as this appears fixed.
I am using the latest mockgen as of today.
When I use mockgen against generated protobuf golang files, the resulting generated mock file is unusable.
These are the errors I get:
It appears that mockgen is not namespacing input fields.
Here is the command I am running:
mockgen --destination=./examples/proto/mock_proto/mock_proto.go --source=./examples/proto/hello.pb.go
Here is the proto file I am running it against:
Against this I run the following command to generate golang protobuf stuff:
protoc -I=./include -I=./vendor/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis -I=./examples/proto/ ./examples/proto/hello.proto --go_out=plugins=grpc:./examples/proto/ --grpc-gateway_out=logtostderr=true:./examples/proto --swagger_out=logtostderr=true:./examples/proto
Here is a snippet from the resulting file:
And then I run the above mockgen against that, and I this snippet:
You can see the problem right here:
func (m *MockHelloClient) EnglishHello(ctx context.Context, in *HelloReq, opts ...grpc.CallOption) (*HelloResp, error) {
It should be:
func (m *MockHelloClient) EnglishHello(ctx context.Context, in *proto.HelloReq, opts ...grpc.CallOption) (*HelloResp, error) {
HelloReq needs an import and needs to be namespaced.
I don't know why this is happening for all my proto files, but doesn't happen for anything else I use mockgen against.