I have gRPC service (say svc1) which invokes another gRPC service, using its gRPC stub (say svc2_client).
I have generated the client mock for svc2_client. Unit tests as per documentation are working fine, i.e. svc2_client is tested using the generated mock.
However, I have svc1 as shown below:
// Synonymous to proto service generated.
type Svc1 struct {
rt svc2pb.Svc2Client
}
// Constructor to get Service.
func NewSvc1(rt svc2pb.Svc2Client) *Svc1 {
return &Svc1{rt}
}
...
...
Expected behavior:
Expecting it to succeed
To Reproduce
Steps to reproduce the behavior:
Returns an error:
=== RUN TestMethod1Svc1
TestMethod1Svc1: svc1.go:40: Unexpected call to *mock_svc2client.MockSvc2Client.Method1([context.Background.WithDeadline(2020-06-22 10:14:25.620736 +0530 IST m=+3.002262784 [2.999757626s]) key1:"1" } ]) at ...server/mocks/svc2client_mock.go:65 because: there are no expected calls of the method "Method1" for that receiver
--- FAIL: TestMethod1Svc1 (0.00s)
Newbie in Go, could you help me out here.
Additional Information:
- gomock mode (source): source
- gomock version or git ref: github.com/golang/mock v1.4.3
- golang version: go version go1.14 darwin/amd64