Skip to content

Commit

Permalink
Merge pull request wooga#7 from adzeitor/master
Browse files Browse the repository at this point in the history
Fix destructive tests
  • Loading branch information
knutin committed Sep 26, 2011
2 parents 7bc3cd1 + 89c98a8 commit 0ff8af2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions test/eredis_tests.erl
Expand Up @@ -6,7 +6,7 @@

get_set_test() ->
C = c(),
?assertEqual({ok, <<"OK">>}, eredis:q(C, ["FLUSHALL"])),
?assertMatch({ok, _}, eredis:q(C, ["DEL", foo])),

?assertEqual({ok, undefined}, eredis:q(C, ["GET", foo])),
?assertEqual({ok, <<"OK">>}, eredis:q(C, ["SET", foo, bar])),
Expand All @@ -15,21 +15,24 @@ get_set_test() ->

delete_test() ->
C = c(),
?assertEqual({ok, <<"OK">>}, eredis:q(C, ["FLUSHALL"])),
?assertMatch({ok, _}, eredis:q(C, ["DEL", foo])),

?assertEqual({ok, <<"OK">>}, eredis:q(C, ["SET", foo, bar])),
?assertEqual({ok, <<"1">>}, eredis:q(C, ["DEL", foo])),
?assertEqual({ok, undefined}, eredis:q(C, ["GET", foo])).

mset_mget_test() ->
C = c(),
?assertEqual({ok, <<"OK">>}, eredis:q(C, ["FLUSHALL"])),
Keys = lists:seq(1, 1000),

?assertMatch({ok, _}, eredis:q(C, ["DEL" | Keys])),

KeyValuePairs = [[K, K*2] || K <- Keys],
ExpectedResult = [list_to_binary(integer_to_list(K * 2)) || K <- Keys],

?assertEqual({ok, <<"OK">>}, eredis:q(C, ["MSET" | lists:flatten(KeyValuePairs)])),
?assertEqual({ok, ExpectedResult}, eredis:q(C, ["MGET" | Keys])).
?assertEqual({ok, ExpectedResult}, eredis:q(C, ["MGET" | Keys])),
?assertMatch({ok, _}, eredis:q(C, ["DEL" | Keys])).

c() ->
Res = eredis:start_link(),
Expand Down

0 comments on commit 0ff8af2

Please sign in to comment.