Skip to content

Instantly share code, notes, and snippets.

@schleyfox
Created May 10, 2010 06:22
Show Gist options
  • Save schleyfox/395747 to your computer and use it in GitHub Desktop.
Save schleyfox/395747 to your computer and use it in GitHub Desktop.
-module(erldis_fail).
-export([test/0, get_key/1]).
test() ->
{ok, Conn} = erldis:connect("localhost", 6379),
erldis:zadd(Conn, "erldis_fail", 4.0, "thing1"),
erldis:zadd(Conn, "erldis_fail", 4.0, "thing2"),
erldis:zadd(Conn, "erldis_fail", 3.5, "thing3"),
erldis:zadd(Conn, "erldis_fail", 2.0, "thing4"),
erldis:zadd(Conn, "erldis_fail", 6.3, "thing5"),
io:format("Expected Result: ~n"),
io:format("~w~n", [erldis:zrevrange(Conn, "erldis_fail", 0, 30)]),
io:format("SNIP ~n~n"),
run_test(Conn, 1000).
get_key(Conn) ->
%erldis:zrevrange_withscores(Conn, "erldis_fail", 0, 30).
Res = erldis:zrevrange(Conn, "erldis_fail", 0, 30),
try 5 = length(Res)
catch
error:{badmatch, _} ->
io:format("~w~n~n", [Res]),
erlang:error(unexpected_result)
end.
run_test(Conn, 0) ->
done;
run_test(Conn, N) ->
spawn_link(erldis_fail, get_key, [Conn]),
run_test(Conn, N-1).
2> erldis_fail:test().
Expected Result:
[<<116,104,105,110,103,53>>,<<116,104,105,110,103,50>>,<<116,104,105,110,103,49>>,<<116,104,105,110,103,51>>,<<116,104,105,110,103,52>>]
SNIP
[<<116,104,105,110,103,53>>]
[<<116,104,105,110,103,50>>]
[<<116,104,105,110,103,49>>]
[<<116,104,105,110,103,51>>]
[<<116,104,105,110,103,52>>]
[<<116,104,105,110,103,53>>,<<116,104,105,110,103,50>>,<<116,104,105,110,103,49>>]
[<<116,104,105,110,103,51>>]
[<<116,104,105,110,103,52>>]
[<<116,104,105,110,103,53>>]
[<<116,104,105,110,103,50>>]
[<<116,104,105,110,103,49>>]
done
=ERROR REPORT==== 10-May-2010::02:19:41 ===
Error in process <0.676.0> with exit value: {unexpected_result,[{erldis_fail,get_key,1}]}
=ERROR REPORT==== 10-May-2010::02:19:41 ===
Error in process <0.678.0> with exit value: {unexpected_result,[{erldis_fail,get_key,1}]}
=ERROR REPORT==== 10-May-2010::02:19:41 ===
Error in process <0.679.0> with exit value: {unexpected_result,[{erldis_fail,get_key,1}]}
=ERROR REPORT==== 10-May-2010::02:19:41 ===
Error in process <0.681.0> with exit value: {unexpected_result,[{erldis_fail,get_key,1}]}
=ERROR REPORT==== 10-May-2010::02:19:41 ===
Error in process <0.680.0> with exit value: {unexpected_result,[{erldis_fail,get_key,1}]}
=ERROR REPORT==== 10-May-2010::02:19:41 ===
Error in process <0.898.0> with exit value: {unexpected_result,[{erldis_fail,get_key,1}]}
=ERROR REPORT==== 10-May-2010::02:19:41 ===
Error in process <0.900.0> with exit value: {unexpected_result,[{erldis_fail,get_key,1}]}
** exception exit: unexpected_result
in function erldis_fail:get_key/1
=ERROR REPORT==== 10-May-2010::02:19:41 ===
Error in process <0.902.0> with exit value: {unexpected_result,[{erldis_fail,get_key,1}]}
=ERROR REPORT==== 10-May-2010::02:19:41 ===
Error in process <0.903.0> with exit value: {unexpected_result,[{erldis_fail,get_key,1}]}
3>
=ERROR REPORT==== 10-May-2010::02:19:41 ===
Error in process <0.904.0> with exit value: {unexpected_result,[{erldis_fail,get_key,1}]}
=ERROR REPORT==== 10-May-2010::02:19:41 ===
Error in process <0.906.0> with exit value: {unexpected_result,[{erldis_fail,get_key,1}]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment