diff --git a/test/cberl_tests.erl b/test/cberl_tests.erl index c463767..08b668a 100644 --- a/test/cberl_tests.erl +++ b/test/cberl_tests.erl @@ -40,44 +40,44 @@ clean_up(_) -> test_set_and_get(_) -> Key = <<"testkey">>, Value = "testval", - ok = cberl:set(?POOLNAME, Key, 0, Value), + {ok, CAS1} = cberl:set(?POOLNAME, Key, 0, Value), Get1 = cberl:get(?POOLNAME, Key), - ok = cberl:set(?POOLNAME, Key, 0, Value, json), + {ok, CAS2} = cberl:set(?POOLNAME, Key, 0, Value, json), Get2 = cberl:get(?POOLNAME, Key), - ok = cberl:set(?POOLNAME, Key, 0, Value, raw_binary), + {ok, CAS3} = cberl:set(?POOLNAME, Key, 0, Value, raw_binary), Get3 = cberl:get(?POOLNAME, Key), - [?_assertMatch({Key, _, Value}, Get1), - ?_assertMatch({Key, _, Value}, Get2), - ?_assertMatch({Key, _, Value}, Get3) + [?_assertMatch({Key, CAS1, Value}, Get1), + ?_assertMatch({Key, CAS2, Value}, Get2), + ?_assertMatch({Key, CAS3, Value}, Get3) ]. test_multi_get(_) -> Value = "testval", Keys = lists:map(fun(N) -> list_to_binary(integer_to_list(N)) end, lists:seq(1, 1000)), - lists:map(fun(Key) -> ok = cberl:set(?POOLNAME, Key, 0, Value) end, Keys), + lists:map(fun(Key) -> {ok, _} = cberl:set(?POOLNAME, Key, 0, Value) end, Keys), [?_assertMatch({<<"1">>,_, "testval"}, lists:nth(1, cberl:mget(?POOLNAME, Keys)))]. test_replace_add(_) -> Key = <<"testkey">>, Value = "testval", - ok = cberl:set(?POOLNAME, Key, 0, Value), + {ok, _} = cberl:set(?POOLNAME, Key, 0, Value), AddFail = cberl:add(?POOLNAME, Key, 0, Value), AddPass = cberl:add(?POOLNAME, <<"testkey1">>, 0, Value), ReplaceFail = cberl:replace(?POOLNAME, <<"notestkey">>, 0, Value), - ok = cberl:replace(?POOLNAME, Key, 0, "testval1"), + {ok, _} = cberl:replace(?POOLNAME, Key, 0, "testval1"), Get1 = cberl:get(?POOLNAME, Key), [?_assertEqual({error, key_eexists}, AddFail), - ?_assertEqual(ok, AddPass), + ?_assertMatch({ok, _}, AddPass), ?_assertEqual({error, key_enoent}, ReplaceFail), ?_assertMatch({Key, _, "testval1"}, Get1) ]. test_append_prepend(_) -> Key = <<"testkey">>, - ok = cberl:set(?POOLNAME, Key, 0, "base", str), - ok = cberl:append(?POOLNAME, Key, "tail"), + {ok, _} = cberl:set(?POOLNAME, Key, 0, "base", str), + {ok, _} = cberl:append(?POOLNAME, Key, "tail"), Get1 = cberl:get(?POOLNAME, Key), - ok = cberl:prepend(?POOLNAME, Key, "head"), + {ok, _} = cberl:prepend(?POOLNAME, Key, "head"), Get2 = cberl:get(?POOLNAME, Key), [?_assertMatch({Key, _, "basetail"}, Get1), ?_assertMatch({Key, _, "headbasetail"}, Get2) @@ -86,7 +86,7 @@ test_append_prepend(_) -> test_get_and_touch(_) -> Key = <<"testkey">>, Value = "testval", - ok = cberl:set(?POOLNAME, Key, 0, Value), + {ok, _} = cberl:set(?POOLNAME, Key, 0, Value), cberl:get_and_touch(?POOLNAME, Key, 1), timer:sleep(5000), [?_assertEqual({Key, {error,key_enoent}}, cberl:get(?POOLNAME, Key))]. @@ -94,7 +94,7 @@ test_get_and_touch(_) -> test_touch(_) -> Key = <<"testkey">>, Value = "testval", - ok = cberl:set(?POOLNAME, Key, 0, Value), + {ok, _} = cberl:set(?POOLNAME, Key, 0, Value), {ok, _} = cberl:touch(?POOLNAME, Key, 1), timer:sleep(5000), [?_assertEqual({Key, {error,key_enoent}}, cberl:get(?POOLNAME, Key))]. @@ -102,7 +102,7 @@ test_touch(_) -> test_remove(_) -> Key = <<"testkey">>, Value = "testval", - ok = cberl:set(?POOLNAME, Key, 0, Value), + {ok, _} = cberl:set(?POOLNAME, Key, 0, Value), ok = cberl:remove(?POOLNAME, Key), [?_assertEqual({Key, {error,key_enoent}}, cberl:get(?POOLNAME, Key))]. @@ -110,18 +110,18 @@ test_lock(_) -> Key = <<"testkey">>, Value = "testval", Value2 = "testval2", - ok = cberl:set(?POOLNAME, Key, 0, Value), + {ok, _} = cberl:set(?POOLNAME, Key, 0, Value), {Key, CAS, _Exp} = cberl:get_and_lock(?POOLNAME, Key, 100000), fun () -> [?assertEqual({error,key_eexists}, cberl:set(?POOLNAME, Key, 0, Value2)), ?assertEqual(ok, cberl:unlock(?POOLNAME, Key, CAS)), - ?assertEqual(ok, cberl:set(?POOLNAME, Key, 0, Value2))] + ?assertMatch({ok, _}, cberl:set(?POOLNAME, Key, 0, Value2))] end. test_flush(_) -> Key = <<"testkey">>, Value = "testval", - ok = cberl:set(?POOLNAME, Key, 0, Value), + {ok, _} = cberl:set(?POOLNAME, Key, 0, Value), fun() -> [?assertMatch(ok, cberl:flush(?POOLNAME, "default")), ?assertMatch({Key, {error, key_enoent}}, cberl:get(?POOLNAME, Key))] @@ -130,7 +130,7 @@ test_flush(_) -> test_flush_1(_) -> Key = <<"testkey">>, Value = "testval", - ok = cberl:set(?POOLNAME, Key, 0, Value), + {ok, _} = cberl:set(?POOLNAME, Key, 0, Value), fun() -> [?assertMatch(ok, cberl:flush(?POOLNAME)), ?assertMatch({Key, {error, key_enoent}}, cberl:get(?POOLNAME, Key))]