How to properly mock riakc_pb_socket with meck?

144 views Asked by At

Using Erlang R16B02, riakc 2.0.0 and meck 0.82:

When trying to mock riakc_pb_socket in my unit tests it blows up. Here's what I get:

> erl -pa ebin deps/*/ebin
Erlang R16B02 (erts-5.10.3) [source-b44b726] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V5.10.3  (abort with ^G)
1> meck:new(riakc_pb_socket).
** exception exit: {compile_forms,{error,[{[],
                                           [{75,erl_lint,{bad_deprecated,{get_index,'_'}}}]}],
                                         [{[],[{75,erl_lint,{undefined_behaviour,[gen_server]}}]}]}}
2>

I found that if I comment this line in riakc_pb_socket.erl and recompile - the problem goes away. Is there a better solution?

-deprecated({get_index,'_', eventually}). 

so afterwards....

> erl -pa ebin deps/*/ebin
Erlang R16B02 (erts-5.10.3) [source-b44b726] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V5.10.3  (abort with ^G)
1> meck:new(riakc_pb_socket).
ok
2> 

> erl -pa ebin deps/*/ebin
Erlang R16B02 (erts-5.10.3) [source-b44b726] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V5.10.3  (abort with ^G)
1> code:which(riakc_pb_socket).
"deps/riakc/ebin/riakc_pb_socket.beam"
2> 

0

There are 0 answers