superruzafa
Behaviour for mock GRPC.Adapter.Gun
Hi.
I’m trying to test a module that performs gRPC calls using the elixir-grpc library.
Such library allows to inject the underlying HTTP client which by default is GRPC.Adapter.Gun.
My idea is to create a mock of this client with Mox and use it in the tests but for this I need some @behaviour to start from.
Do you know if the Gun client is based on some standard behaviour?
Or must I extract the behaviour of this module?
I know I could use grpc_mock but I’d like to avoid it in this case.
Thanks.
First Post!
the-mikedavis
It looks like that library doesn’t define a @behaviour for the gun client so you’ll have to derive it yourself. Based on what I see in lib/grpc/stub.ex, you’ll probably need to write callbacks for these functions:
connect/2disconnect/1send_request/3send_headers/2end_stream/1cancel/2recv_headers/3recv_data_or_trailers/3
If you write up some nice callbacks for these functions I’m sure the library maintainer(s) would appreciate a PR to add it to the project!







