I have a function which add something into the grpc header
func Dummy(ctx context.Context, request *service.Request) error {
err := grpc.SetHeader(ctx, metadata.Pairs("key", "value"))
return err
}
This works fine when it gets called with service.
While writing the unit test case for this, it always fails with:
rpc error: code = Internal desc = grpc: failed to fetch the stream from the context context.TODO
func TestDummy() {
ctx := context.TODO()
err := Dummy(ctx, &service.Request{})
}
I know I can mock grpc.SetHeader
, but I don't want to do that. Is there any other way we can fix this?