Mecking riakc_pb_socket:get/3

Michael Martin mmartin4242 at
Mon Nov 2 10:22:15 EST 2015

Hi all,

I'm trying to meck riakc_pb_socket:get/3 in my eunit tests, and 
consistently get a function_clause error.

The meck:expect looks like:

meck:expect(riakc_pb_socket, get, [Pid, ?RIAK_TYPE_AND_BUCKET, 
?TestOid], {ok, ?TestRiakObject}),

where Pid is a pid, the macro ?RIAK_TYPE_AND_BUCKET evaluates to 
{<<"buckettype">>, <<"bucketname">>},
and ?TestOid evalutes to 

With the exception of the Pid, the other arguments, as well as the 
expected response, are taken from a live,
running system, where the call to riakc_pb_socket:get/3 works as expected.

Looking at the source for riakc_pb_socket:get/3, I see that the -spec 
looks like:

-spec get(pid(), bucket(), key()) -> {ok, riakc_obj()} | {error, term()}.

and the types bucket() and key() are defined as:
-type bucket() :: binary(). %% A bucket name.
-type key() :: binary(). %% A key name.

In reality, when using bucket types, shouldn't the bucket() type be a 
tuple? At any rate, changing it
to tuple() didn't help my case any.

Can anyone show me an example of a working meck:expect for 


More information about the riak-users mailing list